Spaces:
Runtime error
Runtime error
Jonathan Marokhovsky
commited on
Commit
·
8e97c4e
1
Parent(s):
d703a85
Created an extras file to keep track of the demo code I used while playing around with the Carbon Calculator
Browse files- etc/extras.py +50 -0
etc/extras.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
This is code I played around with in the code section of:
|
3 |
+
https://huggingface.co/spaces/boettiger-lab/leafmap
|
4 |
+
"""
|
5 |
+
|
6 |
+
from pystac_client import Client
|
7 |
+
from shapely.geometry import box
|
8 |
+
import shapely
|
9 |
+
import json
|
10 |
+
|
11 |
+
# DELETE BELOW, just making a quick script to add to the carbon Calculator
|
12 |
+
irrecoverable = (
|
13 |
+
"https://data.source.coop/cboettig/carbon/cogs/irrecoverable_c_total_2018.tif"
|
14 |
+
)
|
15 |
+
vulnerable = "https://data.source.coop/cboettig/carbon/cogs/vulnerable_c_total_2018.tif"
|
16 |
+
m = leafmap.Map(center=[41, -69], zoom=5)
|
17 |
+
# COPY BELOW
|
18 |
+
m.add_cog_layer(
|
19 |
+
irrecoverable,
|
20 |
+
palette="greys",
|
21 |
+
name="doomed",
|
22 |
+
transparent_bg=True,
|
23 |
+
opacity=0.5,
|
24 |
+
zoom_to_layer=False,
|
25 |
+
)
|
26 |
+
m.add_cog_layer(
|
27 |
+
vulnerable,
|
28 |
+
palette="oranges",
|
29 |
+
name="at_risk",
|
30 |
+
transparent_bg=True,
|
31 |
+
opacity=0.5,
|
32 |
+
zoom_to_layer=False,
|
33 |
+
)
|
34 |
+
|
35 |
+
aoi_box = box(
|
36 |
+
-70.74295109234716, 41.01426426532743, -69.46303157927986, 42.0218426094371
|
37 |
+
)
|
38 |
+
bbox = aoi_box.bounds
|
39 |
+
|
40 |
+
api_url = "https://earth-search.aws.element84.com/v1"
|
41 |
+
client = Client.open(api_url)
|
42 |
+
search_results = client.search(
|
43 |
+
collections=["sentinel-2-l2a"],
|
44 |
+
bbox=bbox,
|
45 |
+
sortby=["-properties.datetime"],
|
46 |
+
max_items=4,
|
47 |
+
)
|
48 |
+
items = search_results.item_collection()
|
49 |
+
|
50 |
+
m.add_geojson(items.to_dict())
|