xlandsat.load_scene#
- xlandsat.load_scene(path, bands=None, region=None, dtype='float16')[source]#
Load a Landsat scene downloaded from USGS EarthExplorer.
Can read from a folder with
*.TIF
files and an*_MTL.txt
file or directly from a tar archive (compressed or not) without the need to first unpack the archive. The bands are converted to reflectance/temperature units using appropriate scaling parameters and UTM coordinates are set in the returnedxarray.Dataset
.Important
Do not rename the TIF or MTL files. The folder/archive can have any name but TIF and MTL files need their original names.
Note
Only supports Landsat 8 and 9 Collection 2 Level 2 scenes.
- Parameters:
path (str or
pathlib.Path
) – The path to a folder or tar archive containing the files for a given scene. Must include the*_MTL.txt
metadata file. Not all band files need to be present.bands (None or list) – List of band names to load. If None, will load all bands present in the folder/archive. See below for valid band names. Default is None.
region (None or list) – Crop the scene to this bounding box given as a list of West, East, South, and North coordinate values (UTM in meters). If None, no cropping is performed on the scene. Default is None.
dtype (str or numpy dtype object) – The type used for the band arrays. Integer types will result in rounding so floating point is recommended. Default is float16.
- Returns:
scene (
xarray.Dataset
) – The loaded scene including UTM easting and northing as dimensional coordinates, bands as 2D arrays of the given type as variables, and metadata read from the MTL file and other CF compliant fields in theattrs
attribute.
Notes
The valid band names for Landsat 8 and 9 are:
Number
Name
1
"coastal_aerosol"
2
"blue"
3
"green"
4
"red"
5
"nir"
6
"swir1"
7
"swir2"
10
"thermal"