Spaces:
Sleeping
Sleeping
testing
Browse files
app.py
CHANGED
@@ -250,7 +250,7 @@ m.to_streamlit(height=900)
|
|
250 |
#parquet = "https://data.source.coop/cboettig/pad-us-3/pad-mobi.parquet"
|
251 |
parquet = "https://minio.carlboettiger.info/public-biodiversity/pad-us-3/pad-mobi.parquet"
|
252 |
|
253 |
-
|
254 |
|
255 |
|
256 |
# +
|
@@ -260,7 +260,7 @@ us_lower_48_area_m2 = 7.8e+12
|
|
260 |
def summary_table():
|
261 |
x = ibis.memtable({"bucket": ["public", "tribal", "mixed", "private"],
|
262 |
"color": [public_color, tribal_color, mixed_color, private_color]})
|
263 |
-
df = (
|
264 |
group_by(_.bucket).
|
265 |
aggregate(percent_protected = 100 * _.area.sum() / us_lower_48_area_m2,
|
266 |
mean_richness = (_.richness * _.area).sum() / _.area.sum(),
|
@@ -287,7 +287,7 @@ base = alt.Chart(df).encode(
|
|
287 |
|
288 |
area_chart = (
|
289 |
base.mark_arc(innerRadius=50, outerRadius=120) +
|
290 |
-
base.mark_text(radius=
|
291 |
base.mark_text(radius=135, size=20).encode(text="percent_protected:N")
|
292 |
)
|
293 |
|
@@ -312,23 +312,64 @@ rsr_chart = alt.Chart(df).mark_bar().encode(
|
|
312 |
)
|
313 |
# -
|
314 |
|
315 |
-
|
|
|
|
|
|
|
316 |
|
317 |
# +
|
318 |
col1, col2, col3 = st.columns(3)
|
319 |
|
320 |
-
with col1:
|
|
|
321 |
st.altair_chart(area_chart, use_container_width=True)
|
322 |
-
|
323 |
# -
|
324 |
|
325 |
with col2:
|
|
|
326 |
st.altair_chart(richness_chart, use_container_width=True)
|
327 |
|
328 |
|
329 |
with col3:
|
|
|
330 |
st.altair_chart(rsr_chart, use_container_width=True)
|
331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
'''
|
333 |
## Technical errata
|
334 |
|
@@ -358,7 +399,7 @@ The 2018 version of this data product can be found on Microsoft Planetary Comput
|
|
358 |
The original data is provided in the geotiff format (ESRI LayerFiles) at 990 meter resolution, and includes assets subset by various taxonomic groups for three indicators: for 2,216 imperiled species (species with global conservation status of G1, G2 or listed as threatened or endagered under the United States Ednagered Species Act).
|
359 |
The indicators include species richness (the number of imperiled species occurring in a given pixel),
|
360 |
range-size rarity (RSR, the sum of the inverse of the range sizes of each species occurring in a given pixel),
|
361 |
-
and protection-weighted
|
362 |
See [geohub description](https://geohub-natureserve.opendata.arcgis.com/content/e5a6de94cc7b4d5b9204e2cc5d8b6e4e/about) for more details.
|
363 |
Only data from all species for the species richness and RSR metrics is processed here (at the time of writing).
|
364 |
|
|
|
250 |
#parquet = "https://data.source.coop/cboettig/pad-us-3/pad-mobi.parquet"
|
251 |
parquet = "https://minio.carlboettiger.info/public-biodiversity/pad-us-3/pad-mobi.parquet"
|
252 |
|
253 |
+
pad_data = ibis.read_parquet(parquet)
|
254 |
|
255 |
|
256 |
# +
|
|
|
260 |
def summary_table():
|
261 |
x = ibis.memtable({"bucket": ["public", "tribal", "mixed", "private"],
|
262 |
"color": [public_color, tribal_color, mixed_color, private_color]})
|
263 |
+
df = (pad_data.
|
264 |
group_by(_.bucket).
|
265 |
aggregate(percent_protected = 100 * _.area.sum() / us_lower_48_area_m2,
|
266 |
mean_richness = (_.richness * _.area).sum() / _.area.sum(),
|
|
|
287 |
|
288 |
area_chart = (
|
289 |
base.mark_arc(innerRadius=50, outerRadius=120) +
|
290 |
+
base.mark_text(radius=165, size=20).encode(text="bucket") +
|
291 |
base.mark_text(radius=135, size=20).encode(text="percent_protected:N")
|
292 |
)
|
293 |
|
|
|
312 |
)
|
313 |
# -
|
314 |
|
315 |
+
'''
|
316 |
+
## Summary Statistics
|
317 |
+
|
318 |
+
'''
|
319 |
|
320 |
# +
|
321 |
col1, col2, col3 = st.columns(3)
|
322 |
|
323 |
+
with col1:
|
324 |
+
"#### Percent of Continental US Area"
|
325 |
st.altair_chart(area_chart, use_container_width=True)
|
326 |
+
|
327 |
# -
|
328 |
|
329 |
with col2:
|
330 |
+
"#### Mean Species Richness"
|
331 |
st.altair_chart(richness_chart, use_container_width=True)
|
332 |
|
333 |
|
334 |
with col3:
|
335 |
+
"#### Mean Range-Size Rarirty"
|
336 |
st.altair_chart(rsr_chart, use_container_width=True)
|
337 |
|
338 |
+
# +
|
339 |
+
'''
|
340 |
+
## Custom queries
|
341 |
+
|
342 |
+
Input custom python code below to interactively explore the data.
|
343 |
+
|
344 |
+
'''
|
345 |
+
|
346 |
+
col2_1, col2_2 = st.columns(2)
|
347 |
+
|
348 |
+
|
349 |
+
sample_q = '''(
|
350 |
+
ibis.read_parquet('https://minio.carlboettiger.info/public-biodiversity/pad-us-3/pad-mobi.parquet').
|
351 |
+
group_by(_.bucket).
|
352 |
+
aggregate(percent_protected = 100 * _.area.sum() / us_lower_48_area_m2,
|
353 |
+
mean_richness = (_.richness * _.area).sum() / _.area.sum(),
|
354 |
+
mean_rsr = (_.rsr * _.area).sum() / _.area.sum()
|
355 |
+
).
|
356 |
+
mutate(percent_protected = _.percent_protected.round())
|
357 |
+
)
|
358 |
+
'''
|
359 |
+
|
360 |
+
with col2_1:
|
361 |
+
query = st.text_area(
|
362 |
+
label = "Python code:",
|
363 |
+
value = sample_q,
|
364 |
+
height = 300)
|
365 |
+
|
366 |
+
with col2_2:
|
367 |
+
"Output table:"
|
368 |
+
df = eval(sample_q)
|
369 |
+
st.write(df.to_pandas())
|
370 |
+
|
371 |
+
# -
|
372 |
+
|
373 |
'''
|
374 |
## Technical errata
|
375 |
|
|
|
399 |
The original data is provided in the geotiff format (ESRI LayerFiles) at 990 meter resolution, and includes assets subset by various taxonomic groups for three indicators: for 2,216 imperiled species (species with global conservation status of G1, G2 or listed as threatened or endagered under the United States Ednagered Species Act).
|
400 |
The indicators include species richness (the number of imperiled species occurring in a given pixel),
|
401 |
range-size rarity (RSR, the sum of the inverse of the range sizes of each species occurring in a given pixel),
|
402 |
+
and protection-weighted RSR (RSR times the perecent of the range that is unprotected in GAP 1 & Gap 2).
|
403 |
See [geohub description](https://geohub-natureserve.opendata.arcgis.com/content/e5a6de94cc7b4d5b9204e2cc5d8b6e4e/about) for more details.
|
404 |
Only data from all species for the species richness and RSR metrics is processed here (at the time of writing).
|
405 |
|