Skip to content

Commit 94e1f19

Browse files
authored
Merge pull request #111 from wri/dev
Basline indicators - Biodiversity - San jose #103
2 parents 916d65b + ed8a4b5 commit 94e1f19

9 files changed

+2472
-23
lines changed

baseline-indicators/README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@ The baseline indicators attempt to provide insightful metrics at the city scale
1919

2020
## Biodiversity
2121

22+
| Indicator name | Description |Used datasets | Years |
23+
| ------- | ------- | ------- | ------- |
24+
| Number of reported birds | Number of reported birds within the administrative boundaries of the selected city (both metropolitan and municipality levels) | `GBIF`, `geBoundaries` | 2020 |
25+
| Number of reported birds by order | Number of reported birds broken down by orders within the administrative boundaries of the selected city (both metropolitan and municipality levels) | `GBIF`, `geBoundaries` | 2020 |
26+
| Number of reported birds by family | Number of reported birds broken down by family within the administrative boundaries of the selected city (both metropolitan and municipality levels) | `GBIF`, `geBoundaries` | 2020 |
27+
| Number of reported birds by genus | Number of reported birds broken down by genus within the administrative boundaries of the selected city (both metropolitan and municipality levels) | `GBIF`, `geBoundaries` | 2020 |
28+
| Percent of protected area | For each municipality, percent of land protected as a protected area as defined by IUCN or CBD. | `WDPA`, `geBoundaries` | 2020 |
29+
2230
## GHG emissions
2331

2432

2533
# Key results
2634

2735
| Theme | City | Report |
2836
| --- | --- |--- |
29-
| Green space | San-Jose | [Link to the report](https://cities-urbanshift.s3.eu-west-3.amazonaws.com/reports/UrbanShift-Greenspace-Indicators.html) |
30-
| Green space | Kigali | [Link to the report](https://cities-urbanshift.s3.eu-west-3.amazonaws.com/reports/UrbanShift-Greenspace-Indicators-Kigali.html) |
31-
| Green space | Freetown | [Link to the report](https://cities-urbanshift.s3.eu-west-3.amazonaws.com/reports/UrbanShift-Greenspace-Indicators-Freetown.html) |
37+
| Green space | San-Jose | [San-Jose Greenspace basline idicators report](https://cities-urbanshift.s3.eu-west-3.amazonaws.com/reports/UrbanShift-Greenspace-Indicators.html) |
38+
| Green space | Kigali | [Kigali Greenspace basline idicators report](https://cities-urbanshift.s3.eu-west-3.amazonaws.com/reports/UrbanShift-Greenspace-Indicators-Kigali.html) |
39+
| Green space | Freetown | [Freetown Greenspace basline idicators report](https://cities-urbanshift.s3.eu-west-3.amazonaws.com/reports/UrbanShift-Greenspace-Indicators-Freetown.html) |
40+
| Biodiversity | San-Jose | [San-Jose Biodiversity basline idicators report](https://cities-urbanshift.s3.eu-west-3.amazonaws.com/baseline-indicators/biodiversity/reports/UrbanShift-Biodiversity-SanJose.html) |

baseline-indicators/biodiversity/data/boundaries-CRI-San_Jose-ADM2.geojson

+58
Large diffs are not rendered by default.

baseline-indicators/biodiversity/data/boundaries-CRI-San_Jose-municipality.geojson

+38
Large diffs are not rendered by default.

baseline-indicators/biodiversity/data/geoBoundaries-CRI-ADM2_simplified.geojson

+1
Large diffs are not rendered by default.

baseline-indicators/biodiversity/data/geoBoundaries-CRI-ADM3_simplified.geojson

+1
Large diffs are not rendered by default.

baseline-indicators/biodiversity/reports/UrbanShift-Biodiversity-SanJose.Rmd

+282-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "UrbanShift Greenspace Indicators"
2+
title: "UrbanShift Biodiversity Indicators"
33
author: "Saif Shabou"
44
date: "`r format (Sys.time(), '%d %B %Y')`"
55
output:
@@ -76,7 +76,6 @@ These assessments are intended to provide information to evaluate patterns withi
7676

7777
## Data sources
7878

79-
### Global Biodiversity Information Facility (GBIF)
8079

8180
- **Global Biodiversity Information Facility (GBIF)**: [The Global Biodiversity Information Facility (GBIF)](https://www.gbif.org/en/) is an international network and data infrastructure funded by the world's governments and aimed at providing anyone, anywhere, open access to data about all types of life on Earth.
8281

@@ -86,10 +85,22 @@ These assessments are intended to provide information to evaluate patterns withi
8685

8786
## Biodiversity indicators
8887

88+
| Indicator name | Description |Used datasets | Years |
89+
| ------- | ------- | ------- | ------- |
90+
| Number of reported birds | Number of reported birds within the administrative boundaries of the selected city (both metropolitan and municipality levels) | `GBIF`, `geBoundaries` | 2020 |
91+
| Number of reported birds by order | Number of reported birds broken down by orders within the administrative boundaries of the selected city (both metropolitan and municipality levels) | `GBIF`, `geBoundaries` | 2020 |
92+
| Number of reported birds by family | Number of reported birds broken down by family within the administrative boundaries of the selected city (both metropolitan and municipality levels) | `GBIF`, `geBoundaries` | 2020 |
93+
| Number of reported birds by genus | Number of reported birds broken down by genus within the administrative boundaries of the selected city (both metropolitan and municipality levels) | `GBIF`, `geBoundaries` | 2020 |
94+
| Percent of protected area | For each municipality, percent of land protected as a protected area as defined by IUCN or CBD. | `WDPA`, `geBoundaries` | 2020 |
95+
8996
# Case study: San Jose
9097

9198
## Birds
9299

100+
### Metropolitan level
101+
102+
- **Location of reported birds:**
103+
93104
```{r Birds_map, warning=FALSE, message=FALSE, echo = FALSE, eval = TRUE}
94105
# read Boundary
95106
boundary = st_read("https://cities-urbanshift.s3.eu-west-3.amazonaws.com/data/boundaries/CRI-San_Jose-boundary.geojson",
@@ -109,7 +120,11 @@ label_birds2020 <- sprintf(
109120
leaflet(data = boundary, height = 500, width = "100%") %>%
110121
addTiles() %>%
111122
addProviderTiles("OpenStreetMap.France", group = "OSM") %>%
123+
addProviderTiles(providers$CartoDB.DarkMatter , group = "CartoDB") %>%
112124
# addProviderTiles(providers$Stamen.TonerLite, group = "Toner Lite") %>%
125+
# setView(lat = boundary_centroid_lat,
126+
# lng = boundary_centroid_lon,
127+
# zoom = 9) %>%
113128
# Add boundaries
114129
addPolygons(data = boundary,
115130
group = "Administrative boundaries",
@@ -121,6 +136,12 @@ leaflet(data = boundary, height = 500, width = "100%") %>%
121136
dashArray = "",
122137
fillOpacity = 0.3,
123138
bringToFront = FALSE)) %>%
139+
addMarkers(birds2020$lon,
140+
birds2020$lat,
141+
popup = ~as.character(birds2020$family),
142+
label = label_birds2020,
143+
clusterOptions = markerClusterOptions(),
144+
group = "Birds clusters") %>%
124145
# add birds layer
125146
addCircleMarkers(birds2020$lon, birds2020$lat,
126147
radius = 3,
@@ -130,5 +151,263 @@ leaflet(data = boundary, height = 500, width = "100%") %>%
130151
weight = 0.8,
131152
fillOpacity = 0.6,
132153
popup = ~as.character(birds2020$family),
133-
label = label_birds2020)
154+
label = label_birds2020,
155+
group = "Birds observations") %>%
156+
# Layers control
157+
addLayersControl(
158+
baseGroups = c("OSM","CartoDB"),
159+
overlayGroups = c("Birds clusters","Birds observations"),
160+
options = layersControlOptions(collapsed = FALSE)
161+
) %>%
162+
hideGroup("Birds observations")
163+
```
164+
165+
- **Number of reported birds by order:**
166+
167+
```{r Birds_stat_sanjose_orders, warning=FALSE, message=FALSE, echo = FALSE, eval = TRUE}
168+
# orders ----
169+
birds2020_stats_orders = birds2020 %>%
170+
as.data.frame() %>%
171+
group_by(order) %>%
172+
summarise(nb_species = n()) %>%
173+
arrange(desc(nb_species)) %>%
174+
dplyr::select(`order name` = order,
175+
`Number of species`= nb_species)
176+
177+
# plot chart
178+
birds2020_stats_orders %>%
179+
plot_ly(height = 500, width = 900) %>%
180+
add_trace(x = ~factor(`order name`),
181+
y = ~`Number of species`,
182+
marker = list(color = col_BoldRiverBlue),
183+
type = "bar",
184+
orientation = "v") %>%
185+
layout(title = "Number of birds by order (2020)",
186+
xaxis = list(title = '', categoryorder = "array",categoryarray = ~`Number of species`),
187+
yaxis = list(title = 'Number of observations in 2020'))
188+
```
189+
190+
- **Number of reported birds by family:**
191+
192+
```{r Birds_stat_sanjose_family, warning=FALSE, message=FALSE, echo = FALSE, eval = TRUE}
193+
# families ----
194+
195+
birds2020_stats_families = birds2020 %>%
196+
as.data.frame() %>%
197+
group_by(family) %>%
198+
summarise(nb_species = n()) %>%
199+
arrange(desc(nb_species)) %>%
200+
dplyr::select(`family name` = family,
201+
`Number of species`= nb_species)
202+
203+
# plot chart
204+
birds2020_stats_families %>%
205+
plot_ly(height = 500, width = 900) %>%
206+
add_trace(x = ~factor(`family name`),
207+
y = ~`Number of species`,
208+
marker = list(color = col_BoldRiverBlue),
209+
type = "bar",
210+
orientation = "v") %>%
211+
layout(title = "Number of birds by family (2020)",
212+
xaxis = list(title = '', categoryorder = "array",categoryarray = ~`Number of species`),
213+
yaxis = list(title = 'Number of observations in 2020'))
214+
215+
```
216+
217+
- **Number of reported birds by genus:**
218+
219+
```{r Birds_stat_sanjose_genus, warning=FALSE, message=FALSE, echo = FALSE, eval = TRUE}
220+
# genus ----
221+
222+
birds2020_stats_genus = birds2020 %>%
223+
as.data.frame() %>%
224+
group_by(genus) %>%
225+
summarise(nb_species = n()) %>%
226+
arrange(desc(nb_species)) %>%
227+
dplyr::select(`genus name` = genus,
228+
`Number of species`= nb_species)
229+
230+
# plot table
231+
birds2020_stats_genus %>%
232+
arrange(desc(`Number of species`)) %>%
233+
kable() %>%
234+
kable_styling(bootstrap_options = c("striped", "hover"), full_width = F, font_size = 13)%>%
235+
scroll_box(width = "100%", height = "400px")
236+
237+
```
238+
239+
### Municipality level
240+
241+
```{r Birds_map_adm2, warning=FALSE, message=FALSE, echo = FALSE, eval = TRUE}
242+
boundary_municipality = st_read("https://cities-urbanshift.s3.eu-west-3.amazonaws.com/baseline-indicators/biodiversity/data/boundaries-CRI-San_Jose-ADM2.geojson",
243+
quiet = TRUE)
244+
245+
# find birds observations within municipalities polygons
246+
birds_in_geo_adm2 <- st_join(x = birds2020,
247+
y = boundary_municipality,
248+
join = st_within)
249+
250+
# agregate number of birds observations by municipality
251+
birds_in_geo_adm2_stat = birds_in_geo_adm2 %>%
252+
as.data.frame() %>%
253+
count(shapeName.1) %>%
254+
dplyr::select(shapeName.1,
255+
nb_species = n)
256+
257+
# join with geo
258+
birds_adm2_stat_geo = boundary_municipality %>%
259+
left_join(birds_in_geo_adm2_stat,
260+
by = c("shapeName.1"))
261+
262+
# prepare map
263+
264+
# define color palette for urban expansion levels
265+
pal_nbspecieis_municipality <- colorNumeric(palette = "Reds",
266+
domain = birds_adm2_stat_geo$nb_species,
267+
na.color = "transparent",
268+
revers = FALSE)
269+
270+
# define map labels
271+
labels_adm2_nbspecies <- sprintf("<strong>%s</strong><br/>%s: %s %s",
272+
birds_adm2_stat_geo$shapeName.1,
273+
"Observations: ",
274+
round(birds_adm2_stat_geo$nb_species, 2), "") %>%
275+
lapply(htmltools::HTML)
276+
277+
278+
# plot map
279+
leaflet(height = 500, width = "100%") %>%
280+
addTiles() %>%
281+
addProviderTiles(providers$CartoDB.DarkMatter , group = "CartoDB") %>%
282+
addProviderTiles("OpenStreetMap.France", group = "OSM") %>%
283+
addPolygons(data = birds_adm2_stat_geo,
284+
group = "Nb species",
285+
fillColor = ~pal_nbspecieis_municipality(nb_species),
286+
weight = 1,
287+
opacity = 1,
288+
color = "grey",
289+
fillOpacity = 0.7,
290+
label = labels_adm2_nbspecies,
291+
highlightOptions = highlightOptions(color = "black", weight = 2,
292+
bringToFront = FALSE),
293+
labelOptions = labelOptions(
294+
style = list("font-weight" = "normal", padding = "3px 6px"),
295+
textsize = "15px",
296+
direction = "auto")) %>%
297+
addLegend(pal = pal_nbspecieis_municipality,
298+
values = birds_adm2_stat_geo$nb_species,
299+
opacity = 0.9,
300+
title = "Number of species (2020)",
301+
position = "topright",
302+
labFormat = labelFormat(suffix = "")) %>%
303+
# add birds layer
304+
addCircleMarkers(birds2020$lon, birds2020$lat,
305+
radius = 3,
306+
fillColor = col_BoldRiverBlue,
307+
color = "black",
308+
stroke = TRUE,
309+
weight = 0.8,
310+
fillOpacity = 0.6,
311+
label = label_birds2020,
312+
group = "Birds observations") %>%
313+
# Layers control
314+
addLayersControl(
315+
baseGroups = c("CartoDB","OSM"),
316+
overlayGroups = c("Nb species", "Birds observations"),
317+
options = layersControlOptions(collapsed = FALSE)
318+
) %>%
319+
hideGroup("Birds observations")
320+
```
321+
322+
```{r Birds_barplot_adm2, warning=FALSE, message=FALSE, echo = FALSE, eval = TRUE}
323+
# plot chart
324+
birds_in_geo_adm2_stat %>%
325+
arrange(desc(nb_species)) %>%
326+
plot_ly(height = 500, width = 900) %>%
327+
add_trace(x = ~factor(shapeName.1),
328+
y = ~nb_species,
329+
marker = list(color = col_BoldRiverBlue),
330+
type = "bar",
331+
orientation = "v") %>%
332+
layout(title = "Number of birds by municipality (2020)",
333+
xaxis = list(title = '', categoryorder = "array",categoryarray = ~nb_species),
334+
yaxis = list(title = 'Number of observations in 2020'))
134335
```
336+
337+
338+
## Prrtected areas
339+
340+
```{r protected_area_map, warning=FALSE, message=FALSE, echo = FALSE, eval = TRUE}
341+
# protected areas map -----
342+
protected_areas_sanjose = st_read("https://cities-urbanshift.s3.eu-west-3.amazonaws.com/baseline-indicators/biodiversity/data/biodiversity_map_layers_protected_areas_sanjose.geojson",
343+
quiet = TRUE)
344+
345+
leaflet(data = boundary, height = 500, width = "100%") %>%
346+
addTiles() %>%
347+
addProviderTiles(providers$Stamen.TonerLite, group = "Toner Lite") %>%
348+
addProviderTiles("OpenStreetMap.France", group = "OSM") %>%
349+
addProviderTiles(providers$CartoDB.DarkMatter , group = "CartoDB") %>%
350+
# Add boundaries: metropolitan
351+
addPolygons(data = boundary,
352+
group = "Administrative boundaries",
353+
stroke = TRUE, color = col_Black, weight = 3,dashArray = "3",
354+
smoothFactor = 0.3, fill = FALSE, fillOpacity = 0.2,
355+
highlight = highlightOptions(
356+
weight = 5,
357+
color = "#666",
358+
dashArray = "",
359+
fillOpacity = 0.3,
360+
bringToFront = FALSE)) %>%
361+
# Add boundaries: Municipality
362+
addPolygons(data = boundary_municipality,
363+
group = "Municipality boundaries",
364+
stroke = TRUE, color = "gray", weight = 3,dashArray = "3",
365+
smoothFactor = 0.3, fill = TRUE, fillOpacity = 0.2,
366+
highlight = highlightOptions(
367+
weight = 5,
368+
color = "#666",
369+
dashArray = "",
370+
fillOpacity = 0.3,
371+
bringToFront = FALSE)) %>%
372+
# add protected areas layer
373+
addPolygons(data = protected_areas_sanjose,
374+
group = "Protected Areas",
375+
stroke = TRUE, color = col_BoldGrassGreen, weight = 3,dashArray = "3",
376+
smoothFactor = 0.3, fill = TRUE, fillOpacity = 0.8,
377+
highlight = highlightOptions(
378+
weight = 5,
379+
color = col_LightGrassGreen,
380+
dashArray = "",
381+
fillOpacity = 0.3,
382+
bringToFront = FALSE)) %>%
383+
# Layers control
384+
addLayersControl(
385+
baseGroups = c("Toner Lite","OSM","CartoDB"),
386+
overlayGroups = c("Municipality boundaries", "Protected Areas"),
387+
options = layersControlOptions(collapsed = FALSE)
388+
) %>%
389+
hideGroup("Municipality boundaries")
390+
```
391+
392+
393+
```{r protected_area_barplot, warning=FALSE, message=FALSE, echo = FALSE, eval = TRUE}
394+
protectedarea_percent_by_municipality = read.csv("https://cities-urbanshift.s3.eu-west-3.amazonaws.com/baseline-indicators/biodiversity/data/protectedarea_percent_by_municipality.csv")
395+
396+
# rename columns
397+
protectedarea_percent_by_municipality = protectedarea_percent_by_municipality %>%
398+
rename_with(.cols = 1, ~'municpality_name') %>%
399+
rename_with(.cols = 2, ~'percent_protected_area')
400+
401+
# plot chart
402+
protectedarea_percent_by_municipality %>%
403+
arrange(desc(percent_protected_area)) %>%
404+
plot_ly(height = 500, width = 900) %>%
405+
add_trace(x = ~factor(municpality_name),
406+
y = ~percent_protected_area,
407+
marker = list(color = col_BoldRiverBlue),
408+
type = "bar",
409+
orientation = "v") %>%
410+
layout(title = "Percent of protected area by municipality (2020)",
411+
xaxis = list(title = '', categoryorder = "array",categoryarray = ~percent_protected_area),
412+
yaxis = list(title = 'Percent of protected area (%)'))
413+
```

baseline-indicators/biodiversity/reports/UrbanShift-Biodiversity-SanJose.html

+1,732-15
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)