View source: R/MAPI_GridHexagonal.R
MAPI_GridHexagonal | R Documentation |
Build a grid of hexagonal cells according to samples coordinates and a given halfwidth
cell value provided by users (can be computed using MAPI_EstimateHalfwidth
).
If coordinates are in angular units (eg. longitude/latitude) MAPI will try to build a worldwide
"discrete global grid system" using package 'dggridR'.
As the 'dggridR' package is no more available on CRAN, this feature have been removed
and an error is thrown in this case.
See https://github.com/r-barnes/dggridR for more informations.
As an alternative, grids (levels 1 to 11) are downloadable from MAPI website.
MAPI_GridHexagonal(samples, crs, hw, buf = 0)
samples |
a data.frame with names and geographical coordinates of samples. Column names must be: 'ind', 'x', 'y'. Optional column 'errRad' with an error radius for sample locations (eg. GPS uncertainty). |
crs |
coordinate reference system: integer with the EPSG code, or character with proj4string. When using dummy coordinates (eg. simulation output) you may use EPSG:3857 for example. This allows computation but, of course, has no geographical meaning. |
hw |
Halfwidth : side length of hexagonal cells. |
buf |
optional. This parameter allows to expand or shrink the grid by a number of units in the same reference system as the sample geographical coordinates (0 by default, ignored for worldwide grids). |
a spatial object of class 'sf' including the x and y coordinates of cell centers, cell geometry (polygons) and cell id (gid).
data("samples")
# Builds a grid of hexagonal cells according to samples coordinates (columns x and y)
# using the EPSG:3857 projection and an halfwidth cell value of hw=250m.
grid <- MAPI_GridHexagonal(samples, crs=3857, hw=250)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.