Tiny Forests

Published

July 13, 2023

needs(tinyForestR, sf, tidyverse)
library(tinyForestR)
data("tf_latest")

head(tf_latest)
# A tibble: 6 × 13
# Groups:   tf_id [1]
  name.x tf_id name.y value.y     url   stub  plant_date area  trees gps     lat
   <int> <dbl>  <int> <chr>       <chr> <chr> <date>     <chr> <chr> <chr> <dbl>
1      1    85      1 /tiny-fore… http… /85-… 2020-03-14 207m2 "App… GPS:…  51.8
2      1    85      1 /tiny-fore… http… /85-… 2020-03-14 207m2 " Bi… GPS:…  51.8
3      1    85      1 /tiny-fore… http… /85-… 2020-03-14 207m2 " Bi… GPS:…  51.8
4      1    85      1 /tiny-fore… http… /85-… 2020-03-14 207m2 " Bl… GPS:…  51.8
5      1    85      1 /tiny-fore… http… /85-… 2020-03-14 207m2 " Do… GPS:…  51.8
6      1    85      1 /tiny-fore… http… /85-… 2020-03-14 207m2 " El… GPS:…  51.8
# ℹ 2 more variables: lon <dbl>, age <drtn>
uk_countries <- read_sf("https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/Countries_December_2022_UK_BGC/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson")

uk <- st_union(uk_countries)

tf_latest_sf <- tf_latest |>
  st_as_sf(coords = c("lon", "lat"), crs = 4326)

tf_latest_sf |>
  st_intersection(uk) |>
  select(-trees) |>
  filter(tf_id != 328) |>
  mutate(year = year(plant_date)) |>
  ggplot() +
  geom_sf(data = uk) +
  geom_sf(aes(colour = factor(year))) +
  theme_void()
Warning: attribute variables are assumed to be spatially constant throughout
all geometries

Trees

tf_latest |>
  ungroup() |>
  count(trees, sort = TRUE)
# A tibble: 105 × 2
   trees                                     n
   <chr>                                 <int>
 1 " Birch, silver(Betula pendula) "       177
 2 " Hawthorn(Crataegus monogyna) "        177
 3 " Blackthorn(Prunus spinosa) "          166
 4 " Hazel(Corylus avellana) "             155
 5 " Dog Rose(Rosa canina) "               149
 6 " Oak, sessile(Quercus petraea) "       147
 7 " Birch, downy(Betula pubescens) "      146
 8 " Lime, small-leaved(Tilia cordata) "   142
 9 " Hornbeam(Carpinus betulus) "          138
10 " Oak, english(Quercus robur) "         123
# ℹ 95 more rows
tf_wide <- tf_latest |>
  select(tf_id, trees) |>
  group_by(tf_id) |>
  count(trees) |>
  pivot_wider(names_from = "trees", values_from = "n", values_fill = 0)

bind_cols(tf_id = tf_wide$tf_id, richness = tf_wide |>
  vegan::specnumber() ) |>
  count(richness) |>
  ggplot() +
  geom_col(aes(factor(richness), n)) +
  labs(x = "No of species")