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
import matplotlib.pyplot as plt
# 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)
# Make an RGB composite as an xarray.DataArray
rgb = xls.composite(scene, rescale_to=[0.02, 0.2])
# Plot the composite using xarray's plotting machinery
rgb.plot.imshow()
# Annotate the plot with the rich metadata xlandsat adds to the scene
plt.title(f"{rgb.attrs['title']}\n{rgb.attrs['long_name']}")
plt.axis("scaled")
plt.show()
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.