xlandsat.save_scene

Contents

xlandsat.save_scene#

xlandsat.save_scene(path, scene)[source]#

Save a Landsat scene to a tar archive in the USGS EarthExplorer format.

Requires the scene to be in the format returned by load_scene, including all of the original metadata.

The tar archive will contain the bands saved as *.TIF files in unscaled 16-bit unsigned-integers. The metadata is saved to a corresponding *_MTL.txt file. If the scene was cropped, the file metadata will be adjusted to reflect the new UTM bounding box. The lat/lon bounding box will not be updated.

Tip

Do not use this function as a general output format for the scene unless you require compatibility with EarthExplorer. The best way to save a scene is with xarray.Dataset.to_netcdf since it will result in a single file with all metadata preserved. To load the saved scene, use xarray.load_dataset. NetCDF files can also be loaded lazily with xarray.open_dataset to avoid loading the entire scene into memory.

Note

Only supports Landsat 8 and 9 Collection 2 Level 2 scenes.

Parameters:
  • path (str or pathlib.Path) – The desired path of the output tar archive. The file extension can be .tar (uncompressed) or .tar.gz, .tar.xz, or .tar.bz2 to make a compressed archive.

  • scene (xarray.Dataset) – The 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 the attrs attribute.