Read how to setup tscr to the TSC API.
We get Taxon occurrences with their point representation from TSC. Currently, all Fauna and Flora occurrences have only points, not polygons. Flora Populations can be captured as polygons representing the entire population, or a surveyed part of it. While some taxon occurrences might have polygon extents, all have a point representation.
Community occurrences are mostly captured as polygons. Each community polygon has a corresponding point representation (the centroid), but we limit this example to their polygons.
The examples are mutually applicable to taxon polygons and community points.
TSC maintains several types of reference areas, such as DBCA Regions and Districts.
In this example, we download a subset of 10 Areas, parse the data into a table, and display selected columns of the downloaded Areas.
areas %>%
head(10) %>%
dplyr::select("area_type", "name") %>%
dplyr::arrange("area_type") %>%
janitor::clean_names(case="sentence") %>%
knitr::kable()
Area type | Name |
---|---|
Region | Kimberley |
District | East Kimberley |
District | West Kimberley |
Locality | Cape Dommett |
Site | Cape Dommett |
MPA | Lalang-garram / Camden Sound |
Site | Smokey Bay |
Locality | Smokey Bay Area |
Site | Langgi |
MPA | Rowley Shoals |
In this example, we download Areas of all types, convert it to a spatial format (GeoJSON), and display it on a map.
See the Areas API for other possible filters.
We set mapview::mapviewOptions
with some sensible defaults. See the mapview homepage for far more map configuration options.
areas_gj <-
tsc_GET("area",
# query = list(area_type="Region"),
chunk_size = 100) %>%
magrittr::extract2("data") %>%
geojsonio::as.json() %>%
geojsonsf::geojson_sf()
data("areas_gj", package="tscr")
mapview::mapviewOptions(basemaps = c("Esri.WorldImagery",
"Esri.WorldShadedRelief",
"OpenTopoMap",
"OpenStreetMap"),
layers.control.pos = "topright")
mapview::mapview(areas_gj, zcol="area_type")
In this example, we download the point representation of Taxon occurrence records.
We limit the result size to 10 records for demonstration purposes, but this method can also download the entire dataset if the parameter max_records
is omitted.
See the TSC API for the full list of available endpoints.
We show here Taxon Point Occurrences and Community Polygon Occurrences.
Each data field can serve as a filter via the query attribute.
We show some fields as an interactive table. The field as_html
contains rendered content which can be used as a map popup.
tae <- tae_res %>% tsc_parse()
# head(tae) %>% knitr::kable()
tae %>%
dplyr::select(label, encountered_on, geolocation_capture_method, as_html) %>%
janitor::clean_names(case="sentence") %>%
reactable::reactable(filterable=TRUE, sortable = TRUE, searchable = TRUE,
defaultColDef = reactable::colDef(html=TRUE))
We get Taxon occurrences with their point representations from TSC through the API endpoint occ-taxon-points.
Currently, all Fauna and Flora occurrences are georeferenced only with point coordinates, not polygons.
We then get TSC Areas and split them into DBCA Regions and Districts. Caveat: Regions and Districts to not comprehensively cover WA.
Lastly, we get a list of taxonomic names from TSC to resolve taxon IDs from taxon occurrences to names.
Taxon Occurrences (taxon points) are presented as occ
with DBCA Region and District names (where applicable), plus taxonomic names. Community Occurrences (community areas) are named com_occ
.
tsc_tae <- tsc_GET("occ-taxon-points") # 137k records
tsc_cae <- tsc_GET("occ-community-areas")
tsc_taxa <- tsc_GET("taxon") %>%
wastdr::wastd_parse() %>%
dplyr::mutate(name_id = name_id %>% as.character(), taxon = pk)
tsc_areas <- tsc_GET("area") %>%
magrittr::extract2("features") %>%
geojsonio::as.json() %>%
geojsonsf::geojson_sf()
save(tsc_tae, tsc_cae, tsc_taxa, tsc_areas,
file=here::here("data/tsc.RData"), compress="xz")
regions <- tsc_areas %>%
dplyr::filter(area_type == "Region") %>%
dplyr::transmute(region_id = pk, region_name = name)
districts <- tsc_areas %>%
dplyr::filter(area_type == "District") %>%
dplyr::transmute(district_id = pk, district_name = name)
occ <- tsc_tae %>%
magrittr::extract2("features") %>%
geojsonio::as.json() %>%
geojsonsf::geojson_sf() %>%
sf::st_join(regions) %>%
sf::st_join(districts) %>%
dplyr::left_join(tsc_taxa, by="taxon")
com_occ <- tsc_cae %>%
magrittr::extract2("features") %>%
geojsonio::as.json() %>%
geojsonsf::geojson_sf() %>%
sf::st_join(regions) %>%
sf::st_join(districts)
This example demonstrates how to tally taxon occurences by DBCA Regions, which were joined spatially earlier.