cboettig commited on
Commit
13069ad
·
1 Parent(s): 1aade73

here we go

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -53,7 +53,7 @@ Pan and zoom to the desired location on the map. Then, use the map tools to draw
53
  built = "https://huggingface.co/datasets/boettiger-lab/yellowstone/resolve/main/diffs_cog.tif"
54
 
55
 
56
- m = leafmap.Map(center=(-110.6, 45.45), zoom=10)
57
  m.add_basemap("Esri.NatGeoWorldMap")
58
 
59
  ## Map controls sidebar
@@ -66,9 +66,10 @@ with st.sidebar:
66
 
67
  selection = st.radio("Data", cog_layers)
68
  cog = cog_layers[selection]
69
- m.add_cog_layer(cog, palette="reds", name=selection,
70
- transparent_bg=True, opacity = 0.8,
71
- zoom_to_layer=False)
 
72
 
73
 
74
  st_data = m.to_streamlit(height=400, bidirectional=True)
@@ -79,10 +80,12 @@ if polygon is not None:
79
  gdf = read_polygon(polygon)
80
  x = extract_geom(gdf, cog).fillna(0)
81
  count = x.count()
 
82
  area = round(float(area_hectares(gdf)))
 
83
  carbon_total = round(float(x.mean()) * area) # no, mean does not include zeros
84
- col2, col3 = st.columns(3)
85
- col2.metric(label=f"Area", value=f"{area:,} Hectares")
86
  col3.metric(label=f"pixels", value=f"{count:,}")
87
 
88
 
 
53
  built = "https://huggingface.co/datasets/boettiger-lab/yellowstone/resolve/main/diffs_cog.tif"
54
 
55
 
56
+ m = leafmap.Map(center=(-110.6, 45.45), zoom=8)
57
  m.add_basemap("Esri.NatGeoWorldMap")
58
 
59
  ## Map controls sidebar
 
66
 
67
  selection = st.radio("Data", cog_layers)
68
  cog = cog_layers[selection]
69
+ m.add_cog_layer(cog, name=selection, palette="reds",
70
+ opacity = 0.3,
71
+ transparent_bg = True,
72
+ zoom_to_layer=True)
73
 
74
 
75
  st_data = m.to_streamlit(height=400, bidirectional=True)
 
80
  gdf = read_polygon(polygon)
81
  x = extract_geom(gdf, cog).fillna(0)
82
  count = x.count()
83
+ impact_pixels = x.sum()
84
  area = round(float(area_hectares(gdf)))
85
+ impact_area = area * impact_pixels / count
86
  carbon_total = round(float(x.mean()) * area) # no, mean does not include zeros
87
+ col2, col3 = st.columns(2)
88
+ col2.metric(label=f"Area", value=f"{impact_area:,.2f} Hectares")
89
  col3.metric(label=f"pixels", value=f"{count:,}")
90
 
91