03 cog stac
Using Cloud Optimized GeoTIFF (COG) and SpatioTemporal Asset Catalog (STAC)
Uncomment the following line to install leafmap if needed.
# !pip install leafmap
Working with Cloud Optimized GeoTIFF (COG)
A Cloud Optimized GeoTIFF (COG) is a regular GeoTIFF file, aimed at being hosted on a HTTP file server, with an internal organization that enables more efficient workflows on the cloud. It does this by leveraging the ability of clients issuing HTTP GET range requests to ask for just the parts of a file they need.
More information about COG can be found at https://www.cogeo.org/in-depth.html
Some publicly available Cloud Optimized GeoTIFFs:
- https://stacindex.org/
- https://cloud.google.com/storage/docs/public-datasets/landsat
- https://www.digitalglobe.com/ecosystem/open-data
- https://earthexplorer.usgs.gov/
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 here.
import leafmap
Create an interactive map.
Map = leafmap.Map()
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'
Retrieve the bounding box coordinates of the COG file.
leafmap.cog_bounds(url)
[-108.63447456563128, 38.963980238226654, -108.38008268561431, 40.025815049929754]
Retrieve the centroid coordinates of the COG file.
leafmap.cog_center(url)
(-108.5072786256228, 39.49489764407821)
Retrieve the band names of the COG file.
leafmap.cog_bands(url)
['1', '2', '3']
Retrieves the tile layer URL of the COG file.
leafmap.cog_tile(url)
'https://titiler.xyz/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=https%3A%2F%2Fopendata.digitalglobe.com%2Fevents%2Fcalifornia-fire-2020%2Fpre-event%2F2018-02-16%2Fpine-gulch-fire20%2F1030010076004E00.tif&bidx=1&bidx=2&bidx=3&rescale=1.0%2C251.0'
Add a COG layer to the map.
Map.add_cog_layer(url, name="Fire (pre-event)")
url2 = 'https://opendata.digitalglobe.com/events/california-fire-2020/post-event/2020-08-14/pine-gulch-fire20/10300100AAC8DD00.tif'
Map.add_cog_layer(url2, name="Fire (post-event)")
Map
Working with SpatioTemporal Asset Catalog (STAC)
The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information, so it can more easily be indexed and discovered. A 'spatiotemporal asset' is any file that represents information about the earth captured in a certain space and time. The initial focus is primarily remotely-sensed imagery (from satellites, but also planes, drones, balloons, etc), but the core is designed to be extensible to SAR, full motion video, point clouds, hyperspectral, LiDAR and derived data like NDVI, Digital Elevation Models, mosaics, etc. More information about STAC can be found at https://stacspec.org/
Some publicly available SpatioTemporal Asset Catalog (STAC):
For this demo, we will use STAC assets from https://stacindex.org/catalogs/spot-orthoimages-canada-2005#/?t=catalogs
Create an interactive map.
Map = leafmap.Map()
url = 'https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json'
Retrieve the bounding box coordinates of the STAC file.
leafmap.stac_bounds(url)
[-111.6453245, 60.59892389999882, -110.1583693, 61.30928879999903]
Retrieve the centroid coordinates of the STAC file.
leafmap.stac_center(url)
(-110.90184690000001, 60.95410634999892)
Retrieve the band names of the STAC file.
leafmap.stac_bands(url)
['pan', 'B1', 'B2', 'B3', 'B4']
Retrieve the tile layer URL of the STAC file.
leafmap.stac_tile(url, bands=['B3', 'B2', 'B1'])
'https://titiler.xyz/stac/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=https%3A%2F%2Fcanada-spot-ortho.s3.amazonaws.com%2Fcanada_spot_orthoimages%2Fcanada_spot5_orthoimages%2FS5_2007%2FS5_11055_6057_20070622%2FS5_11055_6057_20070622.json&assets=B3&assets=B2&assets=B1'
Add a STAC layer to the map.
Map.add_stac_layer(url, bands=['pan'], name='Panchromatic')
Map.add_stac_layer(url, bands=['B3', 'B2', 'B1'], name='False color')
Map