map_fetch {rgbif} | R Documentation |
Fetch maps of GBIF occurrences
Description
This function is a wrapper for the GBIF mapping api version 2.0. The mapping API is a web map tile service making it straightforward to visualize GBIF content on interactive maps, and overlay content from other sources. It returns tile maps with number of GBIF records per area unit that can be used in a variety of ways, for example in interactive leaflet web maps. Map details are specified by a number of query parameters, some of them optional. Full documentation of the GBIF mapping api can be found at https://www.gbif.org/developer/maps
Usage
map_fetch(
source = "density",
x = 0:1,
y = 0,
z = 0,
format = "@1x.png",
srs = "EPSG:4326",
bin = NULL,
hexPerTile = NULL,
squareSize = NULL,
style = NULL,
taxonKey = NULL,
datasetKey = NULL,
country = NULL,
publishingOrg = NULL,
publishingCountry = NULL,
year = NULL,
basisOfRecord = NULL,
return = "png",
base_style = NULL,
plot_terra = TRUE,
curlopts = list(http_version = 2),
...
)
Arguments
source |
(character) Either |
x |
(integer sequence) the column. Default: 0:1 |
y |
(integer sequence) the row. Default: 0 |
z |
(integer) the zoom. Default: 0 |
format |
(character) The data format, one of:
|
srs |
(character) Spatial reference system. One of:
|
bin |
(character) |
hexPerTile |
(integer) sets the size of the hexagons (the number horizontally across a tile). |
squareSize |
(integer) sets the size of the squares. Choose a factor of 4096 so they tessalate correctly: probably from 8, 16, 32, 64, 128, 256, 512. |
style |
(character) for raster tiles, choose from the available styles. Defaults to classic.point for source="density" and "scaled.circle" for source="adhoc". |
taxonKey |
(integer/numeric/character) search by taxon key, can only supply 1. |
datasetKey |
(character) search by taxon key, can only supply 1. |
country |
(character) search by taxon key, can only supply 1. |
publishingOrg |
(character) search by taxon key, can only supply 1. |
publishingCountry |
(character) search by taxon key, can only supply 1. |
year |
(integer) integer that limits the search to a certain year or,
if passing a vector of integers, multiple years, for example
|
basisOfRecord |
(character) one or more basis of record states to
include records with that basis of record. The full list is: |
return |
(character) Either "png" or "terra". |
base_style |
(character) The style of the base map. |
plot_terra |
(logical) Set whether the terra map be default plotted. |
curlopts |
options passed on to crul::HttpClient |
... |
additional arguments passed to the adhoc interface. |
Details
The default settings, return='png'
, will return a magick-image
png. This image will be a composite image of the the occurrence tiles fetched
and a base map. This map is primarily useful as a high quality image of
occurrence records.
The args x
and y
can both be integer sequences. For example, x=0:3
or
y=0:1
. Note that the tile index starts at 0. Higher values of z
, will
will produce more tiles that can be fetched and stitched together. Selecting
a too high value for x
or y
will produce a blank image.
Setting return='terra'
will return a terra::SpatRaster
object. This
is primarily useful if you were interested in the underlying aggregated
occurrence density data.
See the article
Value
a magick-image
or terra::SpatRaster
object.
Author(s)
John Waller and Laurens Geffert laurensgeffert@gmail.com
References
https://www.gbif.org/developer/maps
https://api.gbif.org/v2/map/demo.html
https://api.gbif.org/v2/map/demo13.html
See Also
Examples
## Not run:
# all occurrences
map_fetch()
# get artic map
map_fetch(srs='EPSG:3031')
# only preserved specimens
map_fetch(basisOfRecord="PRESERVED_SPECIMEN")
# Map of occ in Great Britain
map_fetch(z=3,y=1,x=7:8,country="GB")
# Peguins with artic projection
map_fetch(srs='EPSG:3031',taxonKey=2481660,style='glacier.point',
base_style="gbif-dark")
# occ from a long time ago
map_fetch(year=1600)
# polygon style
map_fetch(style="iNaturalist.poly",bin="hex")
# iNaturalist dataset plotted
map_fetch(datasetKey="50c9509d-22c7-4a22-a47d-8c48425ef4a7",
style="iNaturalist.poly")
# use source="adhoc" for more filters
map_fetch(z=1,
source="adhoc",
iucn_red_list_category="CR",
style="scaled.circles",
base_style='gbif-light')
# cropped map of Hawaii
map_fetch(z=5,x=3:4,y=12,source="adhoc",gadmGid="USA.12_1")
## End(Not run)