Creates a raster density layer from a set of points.

SObin(
  x,
  y = NULL,
  baselayer = NULL,
  ...,
  col = hcl.colors(26, "Viridis"),
  dim = c(512, 512),
  add = TRUE,
  target = NULL,
  source = NULL,
  data.frame = FALSE
)

Arguments

x

longitudes

y

latitudes

baselayer

optional spatial layer to get extent from

...

passed to plot if add = TRUE

col

colours to use if add = TRUE

dim

dimensions of raster to bin to

add

if TRUE, the raster is added to the current plot. An error is thrown if there is no existing plot

target

target projection passed to SOproj

source

source projection of data projection passed to SOproj

data.frame

if true return a data frame instead of a raster.

Value

A raster. If add = TRUE, it is returned invisibly.

Examples

if (FALSE) { # \dontrun{
  SOmap_auto()
  pts <- cbind(lon = runif(1e6, min = -180, max = 180), lat = runif(1e6, min = -90, max = 90))
  bin <- SObin(pts[, 1], pts[, 2], add = TRUE)
} # }