Visualizing Maxar Open Data with Leafmap
The Maxar Open Data Program provides pre- and post-event high-resolution satellite imagery in support of emergency planning, risk assessment, monitoring of staging areas and emergency response, damage assessment, and recovery. Check out the links below for more information.
The Maxar Open Data STAC catalog URL is: https://maxar-opendata.s3.amazonaws.com/events/catalog.json
# !pip install -U leafmap
import leafmap
Retrieve all collections from the Maxar Open Data STAC catalog. Each collection represents a single event.
leafmap.maxar_collections()
Retrieve all collections for a specific event:
collections = leafmap.maxar_child_collections("Kahramanmaras-turkey-earthquake-23")
print(f"The number of collections: {len(collections)}")
collections[:5]
Retrieve all items (tiles) for a specific collection and generate the footprints:
gdf = leafmap.maxar_items(
collection_id="Kahramanmaras-turkey-earthquake-23",
child_id="1050050044DE7E00",
return_gdf=True,
assets=["visual"],
)
gdf.head()
Add the footprints to the map:
m = leafmap.Map()
m.add_gdf(gdf, layer_name="Footprints")
m
Retrieve the COG URLs for all tiles in a collection:
images = gdf["visual"].tolist()
images[:5]
Create a mosaic json file for the collection. You need to install cogeo-mosaic
first using pip install cogeo-mosaic
. Creating a mosaic json file might take a few minutes. Please be patient.
# leafmap.create_mosaicjson(images, output='1050050044DE7E00.json')
Make the mosaic json file available on the web, then you can add the mosaic to the map:
m = leafmap.Map()
url = "https://geospatial.glitch.me/1050050044DE7E00.json"
m.add_stac_layer(url, name="Mosaic")
m.add_gdf(gdf, layer_name="Footprints")
m
Retrieve the footprint of all tiles for a specific event. This might take 15+ minutes. Please be patient.
# gdf = leafmap.maxar_all_items(
# collection_id='Kahramanmaras-turkey-earthquake-23',
# return_gdf=True,
# verbose=True
# )
# gdf.to_file('maxar_footprints.geojson', driver='GeoJSON')
# gdf
Add the footprints to the map:
m = leafmap.Map(center=[36.844461, 37.386475], zoom=8)
# m.add_gdf(gdf, layer_name="Footprints")
url = "https://cdn.glitch.global/cc5b7737-d8d0-4b07-bf2f-867b9009e986/maxar_footprints.geojson?v=1676583955698"
m.add_geojson(url, layer_name="Footprints")
m