grid_data: Function to grid geolocated observations on a map

Description Usage Arguments Value Examples

Description

Data portals such as OBIS typically return tables of geolocated observations upon requests. Gridded data is often used to represent in a synthetic way this type of observations, but although R packages ggplot2 and ggmap are good at representing it, there is no built-in function to go from raw to aggregated data.

Usage

1
2
grid_data(lat, lon, myresolution = 0.5, myzoom = 7, lat_centre = NULL,
  lon_centre = NULL, map = FALSE)

Arguments

lat

is a numerical vector of latitudes for the set of observations.

lon

is a numerical vector of longitudes for the set of observations.

myresolution

is the size of the cells the data is to be aggregated over

myzoom

is the zoom to be applied to plot the gridded data on ggmap map

lat_centre

is the user-defined latitude the map will be centred on. Default to mean latitude of observations.

lon_centre

is the user-defined longitude the map will be centred on. Default to mean longitude of observations.

map

controls whether a map should be computed while running grid_data. It is set by default to FALSE.

Value

grid_data returns a data frame containing the number of observations per cell.

Examples

1
2
3
4
5
6
7
8
library(robis)
library(ggmap)
obs <- occurrence("Gadus morhua", year = 2002)
justchecking <- grid_data(lat = obs$decimalLatitude, lon = obs$decimalLongitude, myresolution = 0.5, myzoom = 4, map = TRUE)
# examine the data
head(justchecking$gridded_data)
# plot the data
justchecking$myplot

MarineEcosystemResearchProgramme/merpData documentation built on May 7, 2019, 2:51 p.m.