04 cog mosaic
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
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [2]:
Copied!
import leafmap
import leafmap
In [3]:
Copied!
# leafmap.update_package()
# leafmap.update_package()
Create an interactive map.
In [4]:
Copied!
m = leafmap.Map()
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:
In [5]:
Copied!
pre_fire_url = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cog_pre_event.txt"
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.
In [6]:
Copied!
# leafmap.cog_mosaic_from_file(pre_fire_url)
# leafmap.cog_mosaic_from_file(pre_fire_url)
In [7]:
Copied!
post_fire_url = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cog_post_event.txt"
post_fire_url = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/cog_post_event.txt"
In [8]:
Copied!
# leafmap.cog_mosaic_from_file(post_fire_url)
# leafmap.cog_mosaic_from_file(post_fire_url)
Add a COG mosaic tile layer to the map.
In [9]:
Copied!
# m.add_cog_mosaic_from_file(pre_fire_url, name="Pre-event", show_footprints=True) #This line might take a while to run
# m.add_cog_mosaic_from_file(pre_fire_url, name="Pre-event", show_footprints=True) #This line might take a while to run
In [10]:
Copied!
# m.add_cog_mosaic_from_file(post_fire_url, name="Post-event", show_footprints=True) #This line might take a while to run
# m.add_cog_mosaic_from_file(post_fire_url, name="Post-event", show_footprints=True) #This line might take a while to run
In [11]:
Copied!
pre_event_tile = (
"https://titiler.xyz/mosaicjson/anonymous.layer_pqmra/tiles/{z}/{x}/{y}@1x?"
)
m.add_tile_layer(pre_event_tile, name="Pre-event", attribution="Maxar")
pre_event_tile = (
"https://titiler.xyz/mosaicjson/anonymous.layer_pqmra/tiles/{z}/{x}/{y}@1x?"
)
m.add_tile_layer(pre_event_tile, name="Pre-event", attribution="Maxar")
In [12]:
Copied!
post_event_tile = (
"https://titiler.xyz/mosaicjson/anonymous.layer_qdano/tiles/{z}/{x}/{y}@1x?"
)
m.add_tile_layer(post_event_tile, name="Post-event", attribution="Maxar")
post_event_tile = (
"https://titiler.xyz/mosaicjson/anonymous.layer_qdano/tiles/{z}/{x}/{y}@1x?"
)
m.add_tile_layer(post_event_tile, name="Post-event", attribution="Maxar")
In [13]:
Copied!
m.set_center(-122.0828, 37.0317, 11)
m.set_center(-122.0828, 37.0317, 11)
In [14]:
Copied!
m
m
Out[14]: