grid_location {SpatialGEV} | R Documentation |
Grid the locations with fixed cell size
Description
Grid the locations with fixed cell size
Usage
grid_location(
lon,
lat,
sp.resolution = 2,
lon.range = range(lon),
lat.range = range(lat)
)
Arguments
lon |
Numeric, |
lat |
Numeric, |
sp.resolution |
Numeric, must be a single value that indicates the minimal unit length of a grid cell. |
lon.range |
Optional vector that indicates the range of |
lat.range |
Optional vector that indicates the range of |
Details
The longitude and latitude of each grid cell are the coordinate of the cell center.
For example, if sp.resolution=1
, then cell_lon=55.5
and cell_lat=22.5
correspond to the
square whose left boundary is 55, right boundary is 56, upper boundary is 23, and lower boundary
is 22.
Value
An n x 3
data frame containing three variables: cell_ind
corresponds to unique id
for each grid cell,
cell_lon
is the longitude of the grid cell, cell_lat
is the latitude of the grid cell.
Since the output data frame retains the order of the input coordinates, the original coordinate
dataset and the output have can be linked one-to-one by the row index.
Examples
longitude <- runif(20, -90, 80)
latitude <- runif(20, 40, 60)
grid_locs <- grid_location(longitude, latitude, sp.resolution=0.5)
cbind(longitude, latitude, grid_locs)