Warning: To complete this tutorial you will need matplotlib
In [1]:
importos# First of all, we need some satellite data. # Let's open a lightweight a Landsat-5 MSS collection 2 tile.path=os.path.abspath("../CI/DATA/LM05_L1TP_200029_19841014_20200902_02_T2.tar")
In [2]:
fromeoreader.readerimportReader# Create the readereoreader=Reader()# This reader is a singleton can be called once and then open all your data.# Use it like a logging.getLogger() instance
In [3]:
fromeoreader.bands.aliasimport*# Open your productprod=eoreader.open(path)# No need to unzip hereprint(prod)
<eoreader.products.optical.l5_product.L5Product object at 0x0000026FEFCB9588>
In [4]:
# Here you have opened your product and you have its object in hands# You can play a little with it to see what it got insideprint(f"Landsat tile: {prod.tile_name}")print(f"Acquisition datetime: {prod.datetime}")
# Open here some more interesting geographical data: extentextent=prod.extent()extent.geometry.iat[0]
Out[5]:
In [6]:
# Open here some more interesting geographical data: footprintfootprint=prod.footprint()footprint.geometry.iat[0]
Out[6]:
See the difference between footprint and extent hereunder:
Without nodata
With nodata
In [7]:
# Select the bands you want to loadbands=[GREEN,NDVI,TIR_1,SHADOWS,HILLSHADE]# Be sure they exist for Landsat-5 MSS sensor:ok_bands=[bandforbandinbandsifprod.has_band(band)]print(to_str(ok_bands))# Landsat-5 MSS doesn't provide TIR and SHADOWS bands
['GREEN', 'NDVI', 'HILLSHADE']
In [8]:
# Load those bands as a dict of xarray.DataArrayband_dict=prod.load(ok_bands)band_dict[GREEN]
# Error in plotting with a listif"long_name"instack.attrs:stack.attrs.pop("long_name")# Plot a subsampled versionstack[:,::10,::10].plot(x="x",y="y",col="z")
Out[14]:
<xarray.plot.facetgrid.FacetGrid at 0x26f91226710>