93 cog inspector
Uncomment the following line to install geemap if needed.
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
In [2]:
Copied!
import geemap
import geemap
If you are using a recently implemented geemap feature that has not yet been released to PyPI or conda-forge, you can uncomment the following line to install the development version from GitHub.
In [3]:
Copied!
# geemap.update_package()
# geemap.update_package()
Create an interactive map.
In [4]:
Copied!
m = geemap.Map()
m = geemap.Map()
Add Cloud Optimized GeoTIFF (COG) from Planetary Computer.
In [5]:
Copied!
collection = "landsat-8-c2-l2"
items = "LC08_L2SP_047027_20201204_02_T1"
collection = "landsat-8-c2-l2"
items = "LC08_L2SP_047027_20201204_02_T1"
In [6]:
Copied!
m.add_stac_layer(
collection=collection,
items=items,
assets="SR_B7,SR_B5,SR_B4",
name="Landsat Band-754",
)
m.add_stac_layer(
collection=collection,
items=items,
assets="SR_B7,SR_B5,SR_B4",
name="Landsat Band-754",
)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [6], in <cell line: 1>() ----> 1 m.add_stac_layer( 2 collection=collection, 3 items=items, 4 assets="SR_B7,SR_B5,SR_B4", 5 name="Landsat Band-754", 6 ) File ~/.local/lib/python3.9/site-packages/geemap/foliumap.py:547, in Map.add_stac_layer(self, url, collection, item, assets, bands, titiler_endpoint, name, attribution, opacity, shown, **kwargs) 519 def add_stac_layer( 520 self, 521 url=None, (...) 531 **kwargs, 532 ): 533 """Adds a STAC TileLayer to the map. 534 535 Args: (...) 545 shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True. 546 """ --> 547 tile_url = stac_tile( 548 url, collection, item, assets, bands, titiler_endpoint, **kwargs 549 ) 550 bounds = stac_bounds(url, collection, item, titiler_endpoint) 551 self.add_tile_layer( 552 url=tile_url, 553 name=name, (...) 556 shown=shown, 557 ) File ~/.local/lib/python3.9/site-packages/geemap/common.py:4553, in stac_tile(url, collection, item, assets, bands, titiler_endpoint, **kwargs) 4540 if ( 4541 (assets is not None) 4542 and ("asset_expression" not in kwargs) 4543 and ("expression" not in kwargs) 4544 and ("rescale" not in kwargs) 4545 ): 4546 stats = stac_stats( 4547 collection=collection, 4548 item=item, 4549 assets=assets, 4550 titiler_endpoint=titiler_endpoint, 4551 ) 4552 percentile_2 = min( -> 4553 [stats[s][list(stats[s].keys())[0]]["percentile_2"] for s in stats] 4554 ) 4555 percentile_98 = max( 4556 [stats[s][list(stats[s].keys())[0]]["percentile_98"] for s in stats] 4557 ) 4558 kwargs["rescale"] = f"{percentile_2},{percentile_98}" File ~/.local/lib/python3.9/site-packages/geemap/common.py:4553, in <listcomp>(.0) 4540 if ( 4541 (assets is not None) 4542 and ("asset_expression" not in kwargs) 4543 and ("expression" not in kwargs) 4544 and ("rescale" not in kwargs) 4545 ): 4546 stats = stac_stats( 4547 collection=collection, 4548 item=item, 4549 assets=assets, 4550 titiler_endpoint=titiler_endpoint, 4551 ) 4552 percentile_2 = min( -> 4553 [stats[s][list(stats[s].keys())[0]]["percentile_2"] for s in stats] 4554 ) 4555 percentile_98 = max( 4556 [stats[s][list(stats[s].keys())[0]]["percentile_98"] for s in stats] 4557 ) 4558 kwargs["rescale"] = f"{percentile_2},{percentile_98}" AttributeError: 'list' object has no attribute 'keys'
In [7]:
Copied!
m.add_stac_layer(
collection=collection,
items=items,
assets="SR_B5,SR_B4,SR_B3",
name="Landsat Band-543",
)
m.add_stac_layer(
collection=collection,
items=items,
assets="SR_B5,SR_B4,SR_B3",
name="Landsat Band-543",
)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [7], in <cell line: 1>() ----> 1 m.add_stac_layer( 2 collection=collection, 3 items=items, 4 assets="SR_B5,SR_B4,SR_B3", 5 name="Landsat Band-543", 6 ) File ~/.local/lib/python3.9/site-packages/geemap/foliumap.py:547, in Map.add_stac_layer(self, url, collection, item, assets, bands, titiler_endpoint, name, attribution, opacity, shown, **kwargs) 519 def add_stac_layer( 520 self, 521 url=None, (...) 531 **kwargs, 532 ): 533 """Adds a STAC TileLayer to the map. 534 535 Args: (...) 545 shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True. 546 """ --> 547 tile_url = stac_tile( 548 url, collection, item, assets, bands, titiler_endpoint, **kwargs 549 ) 550 bounds = stac_bounds(url, collection, item, titiler_endpoint) 551 self.add_tile_layer( 552 url=tile_url, 553 name=name, (...) 556 shown=shown, 557 ) File ~/.local/lib/python3.9/site-packages/geemap/common.py:4553, in stac_tile(url, collection, item, assets, bands, titiler_endpoint, **kwargs) 4540 if ( 4541 (assets is not None) 4542 and ("asset_expression" not in kwargs) 4543 and ("expression" not in kwargs) 4544 and ("rescale" not in kwargs) 4545 ): 4546 stats = stac_stats( 4547 collection=collection, 4548 item=item, 4549 assets=assets, 4550 titiler_endpoint=titiler_endpoint, 4551 ) 4552 percentile_2 = min( -> 4553 [stats[s][list(stats[s].keys())[0]]["percentile_2"] for s in stats] 4554 ) 4555 percentile_98 = max( 4556 [stats[s][list(stats[s].keys())[0]]["percentile_98"] for s in stats] 4557 ) 4558 kwargs["rescale"] = f"{percentile_2},{percentile_98}" File ~/.local/lib/python3.9/site-packages/geemap/common.py:4553, in <listcomp>(.0) 4540 if ( 4541 (assets is not None) 4542 and ("asset_expression" not in kwargs) 4543 and ("expression" not in kwargs) 4544 and ("rescale" not in kwargs) 4545 ): 4546 stats = stac_stats( 4547 collection=collection, 4548 item=item, 4549 assets=assets, 4550 titiler_endpoint=titiler_endpoint, 4551 ) 4552 percentile_2 = min( -> 4553 [stats[s][list(stats[s].keys())[0]]["percentile_2"] for s in stats] 4554 ) 4555 percentile_98 = max( 4556 [stats[s][list(stats[s].keys())[0]]["percentile_98"] for s in stats] 4557 ) 4558 kwargs["rescale"] = f"{percentile_2},{percentile_98}" AttributeError: 'list' object has no attribute 'keys'
In [8]:
Copied!
m
m
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Last update:
2022-03-14