Home

Contents

xlandsat

Analyze Landsat remote sensing images using xarray

_images/logo.svg

xlandsat is Python library for loading and analyzing Landsat scenes downloaded from USGS EarthExplorer with the power of xarray. We take care of reading the metadata from the *_MTL.txt files provided by EarthExplorer and organizing the bands into a single xarray.Dataset data structure for easier manipulation, processing, and visualization.

Here’s a quick example:

import xlandsat as xls

# Download a sample Landsat 9 scene in EarthExplorer format
path_to_scene_file = xls.datasets.fetch_manaus()
# Load the data from the file into an xarray.Dataset
scene = xls.load_scene(path_to_scene_file)
# Display the scene and included metadata
scene
<xarray.Dataset> Size: 5MB
Dimensions:   (easting: 851, northing: 468)
Coordinates:
  * easting   (easting) float64 7kB 8.325e+05 8.325e+05 ... 8.58e+05 8.58e+05
  * northing  (northing) float64 4kB -3.55e+05 -3.55e+05 ... -3.41e+05 -3.41e+05
Data variables:
    blue      (northing, easting) float16 797kB 0.05908 0.05896 ... 0.06665
    green     (northing, easting) float16 797kB 0.07446 0.0752 ... 0.09082
    red       (northing, easting) float16 797kB 0.06152 0.06201 ... 0.1046
    nir       (northing, easting) float16 797kB 0.2915 0.293 ... 0.06409 0.06445
    swir1     (northing, easting) float16 797kB 0.1411 0.1434 ... 0.0509 0.05042
    swir2     (northing, easting) float16 797kB 0.07996 0.08093 ... 0.04968
Attributes: (12/19)
    Conventions:                CF-1.8
    title:                      Landsat 9 scene from 2023-07-23 (path/row=231...
    digital_object_identifier:  https://doi.org/10.5066/P9OGBGM6
    origin:                     Image courtesy of the U.S. Geological Survey
    landsat_product_id:         LC09_L2SP_231062_20230723_20230802_02_T1
    processing_level:           L2SP
    ...                         ...
    ellipsoid:                  WGS84
    date_acquired:              2023-07-23
    scene_center_time:          14:12:31.2799050Z
    wrs_path:                   231
    wrs_row:                    62
    mtl_file:                   GROUP = LANDSAT_METADATA_FILE\n  GROUP = PROD...
# Make an RGB composite as an xarray.DataArray
rgb = xls.composite(scene, rescale_to=[0.02, 0.2])
# Plot the composite on an interactive Leaflet map
xls.plot_composite_leaflet(rgb, height="400px")

Getting started

New to xlandsat? Start here!

Overview

Need help?

Open an Issue on GitHub.

Join the conversation

Reference documentation

A list of available functions.

List of functions and classes (API)

Using for research?

Citations help support our work!

Citing xlandsat


Note

Only Landsat 8 and 9 Level 1 & 2 data products have been tested at the moment.

xlandsat is ready for use but still changing

This means that we sometimes break backwards compatibility as we try to improve the software based on user experience, new ideas, better design decisions, etc. Please keep that in mind before you update xlandsat to a newer version.

We welcome feedback and ideas! This is a great time to bring new ideas on how we can improve the project. Submit issues on GitHub.

Looking for large-scale processing or other satellites?

Our goal is not to provide a solution for large-scale data processing. Our target is smaller scale analysis done on individual computers (which is probably the main way EarthExplorer is used).

  • For cloud-based data processing, see the Pangeo Project.

  • For other satellites and more powerful features, use Satpy.