Spaces:
Sleeping
Sleeping
Update pages/_common.py
Browse files- pages/_common.py +16 -2
pages/_common.py
CHANGED
|
@@ -91,6 +91,7 @@ researcher_name = solara.reactive("Guest Reviewer")
|
|
| 91 |
selected_species = solara.reactive(species_list[0] if species_list else "Acrobatornis fonsecai")
|
| 92 |
|
| 93 |
# Layer visibility
|
|
|
|
| 94 |
show_eoo = solara.reactive(True)
|
| 95 |
show_aoh = solara.reactive(True)
|
| 96 |
show_aoh_removerp = solara.reactive(True)
|
|
@@ -142,6 +143,9 @@ def compute_species_view(fc, fallback_center=FALLBACK_CENTER, fallback_zoom=FALL
|
|
| 142 |
except Exception:
|
| 143 |
return fallback_center, fallback_zoom
|
| 144 |
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
def get_eoo_fc(species: str) -> ee.FeatureCollection:
|
| 147 |
"""EOO polygon(s) for the species (filters by 'species' == Genus_species)."""
|
|
@@ -274,6 +278,17 @@ def create_aoh_map(species: str, height: str = "70vh",
|
|
| 274 |
m = _make_bare_map(sp_centre, sp_zoom, height, draw_control)
|
| 275 |
m.add_basemap("Esri.WorldShadedRelief")
|
| 276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
# EOO outline (blue)
|
| 278 |
try:
|
| 279 |
eoo = get_eoo_fc(species)
|
|
@@ -311,7 +326,7 @@ def create_aoh_map(species: str, height: str = "70vh",
|
|
| 311 |
except Exception as e:
|
| 312 |
print(f"AOH-RP layer error: {e}")
|
| 313 |
|
| 314 |
-
# IUCN range
|
| 315 |
try:
|
| 316 |
iucn = get_iucn_fc(species)
|
| 317 |
m.addLayer(
|
|
@@ -328,7 +343,6 @@ def create_aoh_map(species: str, height: str = "70vh",
|
|
| 328 |
ebird = occs.filter(ee.Filter.stringContains("source", "eBird"))
|
| 329 |
other = occs.filter(ee.Filter.stringContains("source", "eBird").Not())
|
| 330 |
|
| 331 |
-
# Updated to new colors: eBird = #1F78B4, GBIF = #6A3D9A
|
| 332 |
m.addLayer(
|
| 333 |
ebird.style(color="000000", fillColor="1F78B4", width=1, pointSize=5, pointShape="circle"),
|
| 334 |
{}, "Occurrences (eBird)",
|
|
|
|
| 91 |
selected_species = solara.reactive(species_list[0] if species_list else "Acrobatornis fonsecai")
|
| 92 |
|
| 93 |
# Layer visibility
|
| 94 |
+
show_brazil = solara.reactive(True)
|
| 95 |
show_eoo = solara.reactive(True)
|
| 96 |
show_aoh = solara.reactive(True)
|
| 97 |
show_aoh_removerp = solara.reactive(True)
|
|
|
|
| 143 |
except Exception:
|
| 144 |
return fallback_center, fallback_zoom
|
| 145 |
|
| 146 |
+
def get_brazil_fc() -> ee.FeatureCollection:
|
| 147 |
+
"""FAO GAUL level 0 boundary for Brazil."""
|
| 148 |
+
return ee.FeatureCollection("FAO/GAUL/2015/level0").filter(ee.Filter.eq("ADM0_NAME", "Brazil"))
|
| 149 |
|
| 150 |
def get_eoo_fc(species: str) -> ee.FeatureCollection:
|
| 151 |
"""EOO polygon(s) for the species (filters by 'species' == Genus_species)."""
|
|
|
|
| 278 |
m = _make_bare_map(sp_centre, sp_zoom, height, draw_control)
|
| 279 |
m.add_basemap("Esri.WorldShadedRelief")
|
| 280 |
|
| 281 |
+
# Brazil Boundary
|
| 282 |
+
try:
|
| 283 |
+
brazil = get_brazil_fc()
|
| 284 |
+
m.addLayer(
|
| 285 |
+
brazil.style(color="000000", fillColor="00000000", width=2, lineType="dashed"),
|
| 286 |
+
{}, "Brazil Boundary",
|
| 287 |
+
shown=show_brazil.value,
|
| 288 |
+
)
|
| 289 |
+
except Exception as e:
|
| 290 |
+
print(f"Brazil layer error: {e}")
|
| 291 |
+
|
| 292 |
# EOO outline (blue)
|
| 293 |
try:
|
| 294 |
eoo = get_eoo_fc(species)
|
|
|
|
| 326 |
except Exception as e:
|
| 327 |
print(f"AOH-RP layer error: {e}")
|
| 328 |
|
| 329 |
+
# IUCN range
|
| 330 |
try:
|
| 331 |
iucn = get_iucn_fc(species)
|
| 332 |
m.addLayer(
|
|
|
|
| 343 |
ebird = occs.filter(ee.Filter.stringContains("source", "eBird"))
|
| 344 |
other = occs.filter(ee.Filter.stringContains("source", "eBird").Not())
|
| 345 |
|
|
|
|
| 346 |
m.addLayer(
|
| 347 |
ebird.style(color="000000", fillColor="1F78B4", width=1, pointSize=5, pointShape="circle"),
|
| 348 |
{}, "Occurrences (eBird)",
|