37 planetary computer

Uncomment the following line to install leafmap if needed.
Add a STAC item via an HTTP URL
| 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"
|
| # leafmap.stac_stats(url)
|
| m = leafmap.Map()
m.add_stac_layer(url, bands=["B3", "B2", "B1"])
m
|
Add a Microsoft Planetry Computer STAC item. The titiler endpoint can set in one of the ways below:
| os.environ["TITILER_ENDPOINT"] = "planetary-computer"
titiler_endpoint="pc"
titiler_endpoint="planetary-computer"
|
| # import os
# os.environ["TITILER_ENDPOINT"] = "planetary-computer"
|
| collection = "landsat-8-c2-l2"
|
| item = "LC08_L2SP_047027_20201204_02_T1"
|
| leafmap.stac_assets(collection=collection, item=item, titiler_endpoint="pc")
|
| leafmap.stac_bounds(collection=collection, item=item)
|
| leafmap.stac_info(collection=collection, item=item, assets="SR_B7")
|
| leafmap.stac_stats(collection=collection, item=item, assets="SR_B7")
|
Color infrared composite.
| m = leafmap.Map()
m.add_stac_layer(
collection=collection,
item=item,
assets=["SR_B5", "SR_B4", "SR_B3"],
name="Color infrared",
)
m
|
False color composite.
| m = leafmap.Map()
m.add_stac_layer(
collection=collection, item=item, assets="SR_B7,SR_B5,SR_B4", name="False color"
)
m
|
Calculate NDVI.
| m = leafmap.Map()
m.add_stac_layer(
collection=collection,
item=item,
expression="(SR_B5-SR_B4)/(SR_B5+SR_B4)",
rescale="-1,1",
name="NDVI",
)
m
|
Calculate NDVI and add a colormap. See available colormaps at https://planetarycomputer.microsoft.com/docs/reference/data/
1
2
3
4
5
6
7
8
9
10
11
12
13 | m = leafmap.Map()
m.add_stac_layer(
collection=collection, item=item, assets="SR_B5,SR_B4,SR_B3", name="Color infrared"
)
m.add_stac_layer(
collection=collection,
item=item,
expression="(SR_B5-SR_B4)/(SR_B5+SR_B4)",
rescale="-1,1",
colormap_name="greens",
name="NDVI Green",
)
m
|