Last active
September 25, 2025 12:20
-
-
Save martinschwartz95/9b7492a861038eec40c26633a96f8a3e to your computer and use it in GitHub Desktop.
Access FORMS-T data throught the STAC API of MTD using the teledetection package (pip install teledetection). Click the link and login using DataTerra and then ORCID if you have an ORCID or create an account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import matplotlib.pyplot as plt | |
| import pystac_client | |
| import rasterio | |
| import teledetection as tld | |
| # Log in is required. Click the link and login using DataTerra and then ORCID if you have an ORCID or create an account | |
| api = pystac_client.Client.open( | |
| "https://api.stac.teledetection.fr", | |
| modifier=tld.sign_inplace, | |
| ) | |
| # Choose the year and the asset type | |
| year = 2022 | |
| asset_type = "height" | |
| # asset_type = "agbd" | |
| # asset_type = "wvd" | |
| stac_item = ( | |
| api.get_collection("forms-t").get_item(f"FORMS-T-{year}").get_assets()[asset_type] | |
| ) | |
| # Get the URL from the STAC asset | |
| asset_url = stac_item.href | |
| # forest "La Teste de Buch (huge fire in 2022)" | |
| # Coordinates in EPSG: 2154 (Lambert 93, French CRS projection) | |
| aoi = (360386, 6386934, 372469, 6398018) | |
| # Open the raster with rasterio | |
| with rasterio.open(asset_url) as src: | |
| # get the window for the aoi | |
| window = src.window(*aoi) | |
| data = src.read(1, window=window) | |
| # Show the data (units are cm for height) | |
| plt.imshow(data, cmap="magma", vmin=0, vmax=3000) | |
| plt.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment