File size: 1,246 Bytes
8e97c4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
This is code I played around with in the code section of:
    https://huggingface.co/spaces/boettiger-lab/leafmap
"""

from pystac_client import Client
from shapely.geometry import box
import shapely
import json

# DELETE BELOW, just making a quick script to add to the carbon Calculator
irrecoverable = (
    "https://data.source.coop/cboettig/carbon/cogs/irrecoverable_c_total_2018.tif"
)
vulnerable = "https://data.source.coop/cboettig/carbon/cogs/vulnerable_c_total_2018.tif"
m = leafmap.Map(center=[41, -69], zoom=5)
# COPY BELOW
m.add_cog_layer(
    irrecoverable,
    palette="greys",
    name="doomed",
    transparent_bg=True,
    opacity=0.5,
    zoom_to_layer=False,
)
m.add_cog_layer(
    vulnerable,
    palette="oranges",
    name="at_risk",
    transparent_bg=True,
    opacity=0.5,
    zoom_to_layer=False,
)

aoi_box = box(
    -70.74295109234716, 41.01426426532743, -69.46303157927986, 42.0218426094371
)
bbox = aoi_box.bounds

api_url = "https://earth-search.aws.element84.com/v1"
client = Client.open(api_url)
search_results = client.search(
    collections=["sentinel-2-l2a"],
    bbox=bbox,
    sortby=["-properties.datetime"],
    max_items=4,
)
items = search_results.item_collection()

m.add_geojson(items.to_dict())