Skip to content

04 cog mosaic

image image image

Creating a virtual mosaic of Cloud Optimized GeoTIFFs (COG)

Uncomment the following line to install leafmap if needed.

Important Note: This notebook no longer works. The add_cog_mosaic() has been removed from leafmap. See https://github.com/opengeos/leafmap/issues/180

1
# !pip install leafmap
1
import leafmap
1
# leafmap.update_package()

Create an interactive map.

1
m = leafmap.Map()

For this demo, we will use data from https://www.maxar.com/open-data/california-colorado-fires for mapping California and Colorado fires. A List of COGs can be found at:

  • Pre-event: https://github.com/opengeos/leafmap/blob/master/examples/data/cog_pre_event.txt
  • Post-event: https://github.com/opengeos/leafmap/blob/master/examples/data/cog_post_event.txt
1
pre_fire_url = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cog_pre_event.txt"

Create an XYZ tile layer based on a txt file containing a list of COG URLs.

1
# leafmap.cog_mosaic_from_file(pre_fire_url)
1
post_fire_url = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cog_post_event.txt"
1
# leafmap.cog_mosaic_from_file(post_fire_url)

Add a COG mosaic tile layer to the map.

1
# m.add_cog_mosaic_from_file(pre_fire_url, name="Pre-event", show_footprints=True)  #This line might take a while to run
1
# m.add_cog_mosaic_from_file(post_fire_url, name="Post-event", show_footprints=True)   #This line might take a while to run
1
2
pre_event_tile = "https://titiler.opengeos.org/mosaicjson/anonymous.layer_pqmra/tiles/{z}/{x}/{y}@1x?"
m.add_tile_layer(pre_event_tile, name="Pre-event", attribution="Maxar")
1
2
post_event_tile = "https://titiler.opengeos.org/mosaicjson/anonymous.layer_qdano/tiles/{z}/{x}/{y}@1x?"
m.add_tile_layer(post_event_tile, name="Post-event", attribution="Maxar")
1
m.set_center(-122.0828, 37.0317, 11)
1
m