Builds the GBIF SQL download that counts, per grid cell of the study
extent: all records of a reference group (n_records, default vascular
plants), the number of recorded species (n_species, less inflated by a
few huge atlas datasets: the recommended effort proxy) and the records of
a target group of companion species (n_target, for a target-group
background). GBIF aggregates on its side, so the result is one small
table, not millions of records. Run it with download_gbif_effort() and
turn the table into rasters with gbif_effort_rasters(); use a layer as
effort in sample_background().
Usage
gbif_effort_sql(
extent,
cell = 0.1,
taxon_filter = "phylum = 'Tracheophyta'",
target = NULL,
max_uncertainty_m = 10000,
basis = c("HUMAN_OBSERVATION", "PRESERVED_SPECIMEN", "OBSERVATION", "OCCURRENCE",
"MATERIAL_SAMPLE")
)Arguments
- extent
Study extent
c(xmin, xmax, ymin, ymax)in degrees.- cell
Cell size in degrees (default 0.1).
- taxon_filter
SQL condition defining the reference group (default vascular plants:
"phylum = 'Tracheophyta'").- target
Optional species names of the target group (e.g. companions with the same habitat and recorders, without your species itself).
- max_uncertainty_m
Records with a larger stated uncertainty are left out.
- basis
Accepted
basisOfRecordvalues.
Examples
cat(gbif_effort_sql(c(-32, 75, 34, 82),
target = c("Silene acaulis", "Salix herbacea")))
#> SELECT FLOOR(decimalLatitude * 10) AS lat_bin, FLOOR(decimalLongitude * 10) AS lon_bin, COUNT(*) AS n_records, COUNT(DISTINCT speciesKey) AS n_species, SUM(CASE WHEN species IN ('Silene acaulis', 'Salix herbacea') THEN 1 ELSE 0 END) AS n_target FROM occurrence WHERE phylum = 'Tracheophyta' AND hasCoordinate = TRUE AND hasGeospatialIssues = FALSE AND occurrenceStatus = 'PRESENT' AND basisOfRecord IN ('HUMAN_OBSERVATION', 'PRESERVED_SPECIMEN', 'OBSERVATION', 'OCCURRENCE', 'MATERIAL_SAMPLE') AND (coordinateUncertaintyInMeters IS NULL OR coordinateUncertaintyInMeters <= 10000) AND decimalLatitude >= 34 AND decimalLatitude < 82 AND decimalLongitude >= -32 AND decimalLongitude < 75 GROUP BY FLOOR(decimalLatitude * 10), FLOOR(decimalLongitude * 10)
