Morocco earthquake
Visualizing Maxar Open Data for the 2023 Morocco Earthquake 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.
- Maxar Open Data Program
- Maxar Open Data on AWS
- Maxar Open Data on STAC Index
- Maxar Open Data on STAC Browser
The Maxar Open Data STAC catalog URL is: https://maxar-opendata.s3.amazonaws.com/events/catalog.json
# !pip install -U leafmap geopandas cogeo-mosaic
import leafmap.foliumap as leafmap
Retrieve all collections from the Maxar Open Data STAC catalog. Each collection represents a single event.
leafmap.maxar_collections()
['BayofBengal-Cyclone-Mocha-May-23', 'Emilia-Romagna-Italy-flooding-may23', 'Gambia-flooding-8-11-2022', 'Hurricane-Fiona-9-19-2022', 'Hurricane-Ian-9-26-2022', 'Hurricane-Idalia-Florida-Aug23', 'Indonesia-Earthquake22', 'Kahramanmaras-turkey-earthquake-23', 'Kalehe-DRC-Flooding-5-8-23', 'Libya-Floods-Sept-2023', 'Marshall-Fire-21-Update', 'Maui-Hawaii-fires-Aug-23', 'McDougallCreekWildfire-BC-Canada-Aug-23', 'Morocco-Earthquake-Sept-2023', 'NWT-Canada-Aug-23', 'New-Zealand-Flooding22', 'New-Zealand-Flooding23', 'Sudan-flooding-8-22-2022', 'afghanistan-earthquake22', 'cyclone-emnati22', 'ghana-explosion22', 'kentucky-flooding-7-29-2022', 'pakistan-flooding22', 'shovi-georgia-landslide-8Aug23', 'southafrica-flooding22', 'tonga-volcano21', 'volcano-indonesia21', 'yellowstone-flooding22']
Retrieve all collections for a specific event:
collections = leafmap.maxar_child_collections("Morocco-Earthquake-Sept-2023")
print(f"The number of collections: {len(collections)}")
The number of collections: 244
collections.sort()
collections
Retrieve all items (tiles) for a specific collection and generate the footprints:
gdf = leafmap.maxar_items(
collection_id="Morocco-Earthquake-Sept-2023",
child_id="10300100ECC53700",
return_gdf=True,
assets=["visual"],
)
gdf.head()
geometry | datetime | platform | gsd | ard_metadata_version | catalog_id | utm_zone | quadkey | view:off_nadir | view:azimuth | ... | view:sun_azimuth | view:sun_elevation | proj:epsg | proj:geometry | grid:code | proj:bbox | tile:data_area | tile:clouds_area | tile:clouds_percent | visual | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | POLYGON ((-8.99837 30.61125, -8.99837 30.59612... | 2023-09-10T11:46:24Z | WV02 | 0.83 | 0.0.1 | 10300100ECC53700 | 29 | 031313133131 | 41.5 | 234.2 | ... | 154.6 | 62.3 | 32629 | {'type': 'Polygon', 'coordinates': [[[500155.9... | MXRA-Z29-031313133131 | 497536.92626953125,3384843.75,500156.25,338652... | 3.2 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... |
1 | POLYGON ((-9.02553 30.59894, -8.99837 30.59894... | 2023-09-10T11:46:24Z | WV02 | 0.82 | 0.0.1 | 10300100ECC53700 | 29 | 031313133133 | 41.5 | 234.2 | ... | 154.6 | 62.3 | 32629 | {'type': 'Polygon', 'coordinates': [[[497552.1... | MXRA-Z29-031313133133 | 497552.18505859375,3379843.75,500156.25,338515... | 13.6 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... |
2 | POLYGON ((-9.02489 30.55382, -8.99837 30.55383... | 2023-09-10T11:46:25Z | WV02 | 0.82 | 0.0.1 | 10300100ECC53700 | 29 | 031313133311 | 41.4 | 234.4 | ... | 154.6 | 62.3 | 32629 | {'type': 'Polygon', 'coordinates': [[[497612.6... | MXRA-Z29-031313133311 | 497612.60986328125,3374843.75,500156.25,338015... | 13.3 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... |
3 | POLYGON ((-9.02435 30.50870, -8.99837 30.50871... | 2023-09-10T11:46:25Z | WV02 | 0.82 | 0.0.1 | 10300100ECC53700 | 29 | 031313133313 | 41.4 | 234.6 | ... | 154.6 | 62.3 | 32629 | {'type': 'Polygon', 'coordinates': [[[497663.2... | MXRA-Z29-031313133313 | 497663.26904296875,3369843.75,500156.25,337515... | 13.1 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... |
4 | POLYGON ((-9.02396 30.46358, -8.99837 30.46359... | 2023-09-10T11:46:25Z | WV02 | 0.82 | 0.0.1 | 10300100ECC53700 | 29 | 031313133331 | 41.4 | 234.8 | ... | 154.6 | 62.4 | 32629 | {'type': 'Polygon', 'coordinates': [[[497699.8... | MXRA-Z29-031313133331 | 497604.3701171875,3364843.75,500156.25,3370156.25 | 13.1 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... |
5 rows × 21 columns
Add the footprints to the map:
m = leafmap.Map()
m.add_gdf(gdf, layer_name="Footprints", zoom_to_layer=True, info_mode="on_click")
m
Retrieve the COG URLs for all tiles in a collection:
images = gdf["visual"].tolist()
images[:5]
['https://maxar-opendata.s3.amazonaws.com/events/Morocco-Earthquake-Sept-2023/ard/29/031313133131/2023-09-10/10300100ECC53700-visual.tif', 'https://maxar-opendata.s3.amazonaws.com/events/Morocco-Earthquake-Sept-2023/ard/29/031313133133/2023-09-10/10300100ECC53700-visual.tif', 'https://maxar-opendata.s3.amazonaws.com/events/Morocco-Earthquake-Sept-2023/ard/29/031313133311/2023-09-10/10300100ECC53700-visual.tif', 'https://maxar-opendata.s3.amazonaws.com/events/Morocco-Earthquake-Sept-2023/ard/29/031313133313/2023-09-10/10300100ECC53700-visual.tif', 'https://maxar-opendata.s3.amazonaws.com/events/Morocco-Earthquake-Sept-2023/ard/29/031313133331/2023-09-10/10300100ECC53700-visual.tif']
Download the COGs to a local directory:
leafmap.maxar_download(images[:2])
/media/hdd/Dropbox/git/amazon/maxar-open-data/examples/10300100ECC53700/031313133131.tif already exists. Skipping... /media/hdd/Dropbox/git/amazon/maxar-open-data/examples/10300100ECC53700/031313133133.tif already exists. Skipping...
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='10300100ECC53700.json')
Make the mosaic json file available on the web, then you can add the mosaic to the map:
m = leafmap.Map(height="600px")
m.add_basemap("SATELLITE")
url = "https://open.gishub.org/maxar-open-data/datasets/Morocco-Earthquake-Sept-2023/10300100ECC53700.json"
m.add_stac_layer(url, name="Mosaic")
m.add_gdf(gdf, layer_name="Footprints", info_mode="on_click")
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='Morocco-Earthquake-Sept-2023',
# return_gdf=True,
# verbose=True
# )
# gdf.to_file('maxar_footprints.geojson', driver='GeoJSON')
# gdf
Add the footprints to the map:
m = leafmap.Map(center=[31.35874, -8.78226], zoom=8)
url = "https://raw.githubusercontent.com/opengeos/maxar-open-data/master/datasets/Morocco-Earthquake-Sept-2023_union.geojson"
m.add_geojson(url, layer_name="Footprints", info_mode="on_click")
m
You can find the list of all available images at Morocco-Earthquake-Sept-2023.tsv.
gdf = leafmap.geojson_to_gdf(url)
gdf.head()
datetime | platform | gsd | ard_metadata_version | catalog_id | utm_zone | quadkey | view:off_nadir | view:azimuth | view:incidence_angle | view:sun_azimuth | view:sun_elevation | proj:epsg | grid:code | proj:bbox | tile:data_area | tile:clouds_area | tile:clouds_percent | visual | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2018-08-31 11:25:53+00:00 | WV04 | 0.37 | 0.0.1 | 04eddade-a2dc-4d16-8710-fb764d318766-inv | 29 | 031313133120 | 25.4 | 121.8 | 61.9 | 139.1 | 62.6 | 32629 | MXRA-Z29-031313133120 | 483190.3076171875,3384843.75,485156.25,3385087... | 0.3 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-9.17602 30.32703, -9.17603 30.32811... |
1 | 2010-08-26 11:38:32+00:00 | WV02 | 0.48 | 0.0.1 | 1030010006CA6400 | 29 | 120200233033 | 12.0 | 284.1 | 76.5 | 147.3 | 65.3 | 32629 | MXRA-Z29-120200233033 | 639438.4765625,3539843.75,640156.25,3543812.25... | 2.7 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-7.52311 31.06177, -7.52282 31.06705... |
2 | 2011-08-26 11:31:38+00:00 | WV02 | 0.50 | 0.0.1 | 103001000DA1E700 | 29 | 120200322030 | 15.8 | 147.0 | 72.2 | 144.4 | 64.7 | 32629 | MXRA-Z29-120200322030 | 672485.6567382812,3544843.75,675156.25,3546388... | 4.0 | 0.4 | 11 | https://maxar-opendata.s3.amazonaws.com/events... | MULTIPOLYGON (((-7.16634 31.04317, -7.16631 31... |
3 | 2012-08-29 11:54:08+00:00 | WV02 | 0.48 | 0.0.1 | 103001001A7CAE00 | 29 | 120200220023 | 9.4 | 288.2 | 79.4 | 154.8 | 64.9 | 32629 | MXRA-Z29-120200220023 | 508232.06948724756,3579843.75,510156.25,358154... | 2.6 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-8.89582 31.96387, -8.93980 31.96420... |
4 | 2013-11-12 11:42:03+00:00 | WV02 | 0.48 | 0.0.1 | 10300100295F5E00 | 29 | 120200222032 | 10.1 | 156.6 | 78.7 | 168.5 | 39.6 | 32629 | MXRA-Z29-120200222032 | 514152.52685546875,3539843.75,515156.25,354183... | 1.9 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-8.80616 30.96769, -8.81327 30.96744... |
before = gdf[gdf["datetime"] < "2023-09-10"]
len(before)
226
before.head()
datetime | platform | gsd | ard_metadata_version | catalog_id | utm_zone | quadkey | view:off_nadir | view:azimuth | view:incidence_angle | view:sun_azimuth | view:sun_elevation | proj:epsg | grid:code | proj:bbox | tile:data_area | tile:clouds_area | tile:clouds_percent | visual | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2018-08-31 11:25:53+00:00 | WV04 | 0.37 | 0.0.1 | 04eddade-a2dc-4d16-8710-fb764d318766-inv | 29 | 031313133120 | 25.4 | 121.8 | 61.9 | 139.1 | 62.6 | 32629 | MXRA-Z29-031313133120 | 483190.3076171875,3384843.75,485156.25,3385087... | 0.3 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-9.17602 30.32703, -9.17603 30.32811... |
1 | 2010-08-26 11:38:32+00:00 | WV02 | 0.48 | 0.0.1 | 1030010006CA6400 | 29 | 120200233033 | 12.0 | 284.1 | 76.5 | 147.3 | 65.3 | 32629 | MXRA-Z29-120200233033 | 639438.4765625,3539843.75,640156.25,3543812.25... | 2.7 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-7.52311 31.06177, -7.52282 31.06705... |
2 | 2011-08-26 11:31:38+00:00 | WV02 | 0.50 | 0.0.1 | 103001000DA1E700 | 29 | 120200322030 | 15.8 | 147.0 | 72.2 | 144.4 | 64.7 | 32629 | MXRA-Z29-120200322030 | 672485.6567382812,3544843.75,675156.25,3546388... | 4.0 | 0.4 | 11 | https://maxar-opendata.s3.amazonaws.com/events... | MULTIPOLYGON (((-7.16634 31.04317, -7.16631 31... |
3 | 2012-08-29 11:54:08+00:00 | WV02 | 0.48 | 0.0.1 | 103001001A7CAE00 | 29 | 120200220023 | 9.4 | 288.2 | 79.4 | 154.8 | 64.9 | 32629 | MXRA-Z29-120200220023 | 508232.06948724756,3579843.75,510156.25,358154... | 2.6 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-8.89582 31.96387, -8.93980 31.96420... |
4 | 2013-11-12 11:42:03+00:00 | WV02 | 0.48 | 0.0.1 | 10300100295F5E00 | 29 | 120200222032 | 10.1 | 156.6 | 78.7 | 168.5 | 39.6 | 32629 | MXRA-Z29-120200222032 | 514152.52685546875,3539843.75,515156.25,354183... | 1.9 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-8.80616 30.96769, -8.81327 30.96744... |
after = gdf[gdf["datetime"] >= "2023-09-10"]
len(after)
12
after.head()
datetime | platform | gsd | ard_metadata_version | catalog_id | utm_zone | quadkey | view:off_nadir | view:azimuth | view:incidence_angle | view:sun_azimuth | view:sun_elevation | proj:epsg | grid:code | proj:bbox | tile:data_area | tile:clouds_area | tile:clouds_percent | visual | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
41 | 2023-09-10 11:46:24+00:00 | WV02 | 0.83 | 0.0.1 | 10300100ECC53700 | 29 | 031313133131 | 41.5 | 234.2 | 42.0 | 154.6 | 62.3 | 32629 | MXRA-Z29-031313133131 | 497536.92626953125,3384843.75,500156.25,338652... | 3.2 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-8.94962 30.32099, -8.94962 30.32100... |
42 | 2023-09-10 11:46:13+00:00 | WV02 | 0.86 | 0.0.1 | 10300100ED11EA00 | 29 | 120202003030 | 42.6 | 235.8 | 40.6 | 156.3 | 61.8 | 32629 | MXRA-Z29-120202003030 | 554911.8041992188,3464843.75,555156.25,3466014... | 0.2 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-8.42230 30.99072, -8.42231 30.99033... |
58 | 2023-09-10 11:44:16+00:00 | WV02 | 0.62 | 0.0.1 | 10300500E4F91400 | 29 | 120202000032 | 30.8 | 309.6 | 54.9 | 154.6 | 61.3 | 32629 | MXRA-Z29-120202000032 | 511449.89013671875,3499843.75,515156.25,350205... | 6.9 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-8.78141 31.43107, -8.78790 31.43212... |
59 | 2023-09-10 11:44:26+00:00 | WV02 | 0.64 | 0.0.1 | 10300500E4F91500 | 29 | 120202003202 | 32.4 | 305.2 | 53.1 | 154.9 | 61.8 | 32629 | MXRA-Z29-120202003202 | 540894.1650390625,3449843.75,541899.4140625,34... | 0.0 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-8.44168 30.91998, -8.44655 30.92183... |
60 | 2023-09-10 11:44:54+00:00 | WV02 | 0.64 | 0.0.1 | 10300500E4F91700 | 29 | 120202012023 | 33.0 | 280.7 | 52.4 | 156.2 | 61.9 | 32629 | MXRA-Z29-120202012023 | 585154.1137695312,3459843.75,590156.25,3464666... | 23.2 | 0.0 | 0 | https://maxar-opendata.s3.amazonaws.com/events... | POLYGON ((-7.94900 31.17297, -7.95399 31.17331... |
m = leafmap.Map()
m.add_gdf(before, layer_name="Before", info_mode="on_click")
style_dict = {"color": "red", "fillColor": "red", "fillOpacity": 0.1}
style_function = lambda x: style_dict
m.add_gdf(
after, layer_name="After", info_mode="on_click", style_function=style_function
)
m