Step 4: Output and visualisation
Source:vignettes/step4-output-and-visualisation.Rmd
step4-output-and-visualisation.RmdGoal
The records were assigned to biomes in Step 3. This
final step summarises the result per biome with
biomes_tab() and visualises the whole
workflow with biomes_visualise().
1. Tabulate records per biome
biomes_tab() counts occurrence records
(one input row = one record) per biome and scheme, returning a long
table with one row per (scheme, biome) pair:
classified <- biomes_classify(bombacoideae_occurrences, scheme = 1)
#> Coordinates provided as data.frame, assuming WGS84 as CRS.
#> Classified 17030 record(s) against 1 biome layer(s):
#> - Biome_Inventory_layer_01 (Allen et al., 2020)
biomes_tab(classified)
#> scheme biome n
#> 1 Biome_Inventory_layer_01 Boreal evergreen needleleaf forest 1
#> 2 Biome_Inventory_layer_01 Boreal parkland 81
#> 3 Biome_Inventory_layer_01 Boreal summergreen broadleaf forest 6
#> 4 Biome_Inventory_layer_01 Desert 2
#> 5 Biome_Inventory_layer_01 no_biome 1031
#> 6 Biome_Inventory_layer_01 Savanna 1316
#> 7 Biome_Inventory_layer_01 Semidesert 149
#> 8 Biome_Inventory_layer_01 Steppe 3
#> 9 Biome_Inventory_layer_01 Temperate broadleaf evergreen forest 876
#> 10 Biome_Inventory_layer_01 Temperate needleleaf evergreen forest 141
#> 11 Biome_Inventory_layer_01 Temperate parkland 186
#> 12 Biome_Inventory_layer_01 Temperate shrubland 236
#> 13 Biome_Inventory_layer_01 Tropical evergreen forest 7405
#> 14 Biome_Inventory_layer_01 Tropical grassland 860
#> 15 Biome_Inventory_layer_01 Tropical raingreen forest 4367
#> 16 Biome_Inventory_layer_01 Warm temperate woodland 370The returned columns are scheme, biome and
n. To count unique species per biome
instead of records, deduplicate by species first:
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:terra':
#>
#> intersect, union
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
classified |>
distinct(species, Biome_Inventory_layer_01_name) |>
biomes_tab()
#> scheme biome n
#> 1 Biome_Inventory_layer_01 Boreal evergreen needleleaf forest 1
#> 2 Biome_Inventory_layer_01 Boreal parkland 1
#> 3 Biome_Inventory_layer_01 Boreal summergreen broadleaf forest 3
#> 4 Biome_Inventory_layer_01 Desert 2
#> 5 Biome_Inventory_layer_01 no_biome 59
#> 6 Biome_Inventory_layer_01 Savanna 42
#> 7 Biome_Inventory_layer_01 Semidesert 2
#> 8 Biome_Inventory_layer_01 Steppe 2
#> 9 Biome_Inventory_layer_01 Temperate broadleaf evergreen forest 47
#> 10 Biome_Inventory_layer_01 Temperate needleleaf evergreen forest 21
#> 11 Biome_Inventory_layer_01 Temperate parkland 16
#> 12 Biome_Inventory_layer_01 Temperate shrubland 14
#> 13 Biome_Inventory_layer_01 Tropical evergreen forest 157
#> 14 Biome_Inventory_layer_01 Tropical grassland 22
#> 15 Biome_Inventory_layer_01 Tropical raingreen forest 110
#> 16 Biome_Inventory_layer_01 Warm temperate woodland 102. Visualise the workflow
biomes_visualise() draws up to three panels for a set of
occurrence records:
- rank: the ranking of the biome schemes (best highlighted);
- map: the occurrence records (red points) over the chosen scheme, with the number of records per biome appended to the legend labels;
- barplot: the number of records and species per biome.
By default all three are drawn and lettered a, b, c.
If scheme is NULL, the best-fitting scheme is
chosen by biomes_rank() (within
definition).
biomes_visualise(bombacoideae_occurrences) # rank + map + barplot
#> <SpatRaster> resampled to 5e+05 cells.
Select individual panels with panels; the panel letters
adjust to the selection (e.g. panels = c("map", "barplot")
labels them a and b):
# just the map, for a fixed scheme
biomes_visualise(bombacoideae_occurrences, scheme = 1, panels = "map")
#> <SpatRaster> resampled to 5e+05 cells.
The red points are the occurrence records you
supplied. Drop the record counts from the legend labels with
legend_counts = FALSE, or the whole colour legend with
legend = FALSE. Save any panel with
ggplot2::ggsave():
p <- biomes_visualise(bombacoideae_occurrences, scheme = 1, panels = "map", legend = FALSE)
ggplot2::ggsave("biome_map.jpg", p, width = 13, height = 8, dpi = 600)The whole workflow in one call
Steps 1-4 are wrapped by biomes_full(), which by default
ranks across all 31 schemes and uses the best one. No figure is drawn by
default (plot = "none", the fastest option).
plot = "all" returns the combined lettered
figure in res$plot:
res <- biomes_full(x = bombacoideae_occurrences, plot = "all") # scheme = "best"
res$scheme # the chosen biome scheme number
res$table # records per biome
res$plot # the combined figure (rank + map + barplot)A subset of c("rank", "map", "barplot") returns the
panels individually (no panel letters), each in its own
component res$rank, res$map,
res$barplot:
res <- biomes_full(x = bombacoideae_occurrences, plot = c("rank", "map", "barplot"))
res$map # just the map panel, on its own
res$barplot # just the barplot panelTo force a specific scheme, pass its number
(scheme = 1); to rank within one group, pass a biome
definition (scheme = "vegetation"). Reach for the
individual functions when you want to tweak a step; use
biomes_full() when you want the standard pipeline in one
call.
Done
That completes the four-step workflow: assemble → choose a scheme → classify → output and visualise. Back to Step 1.