Description Usage Arguments Details Value Note Author(s) Examples
View source: R/points2polygrid.R
points2polygrid
determines a fine grid, such that each point is represented by a set of grid cells (nearest neighbourhood); to each grid cell it assigns the values of the nearest point. It may also assign cells of a given grid to the nearest neighbour points.
1 2 |
points |
coordinates of the original points: |
grid |
target grid: |
index |
target index indicating for each grid cell the associated data: integer, length must fit number of cells in grid (order: top left to right, then to bottom) |
data |
data associated with points, to be assigned to grid cells: |
tolerance |
lower limit of the resolution of the generated grid, default generates about 1000 x 1000 grid cells; if points lie on a regular grid, the resulting resolution is automatically adapted |
It is sufficient to provide points
, they can be used to generate a grid and associate the cells to the closest points. The generated grid covers all points; resolution is chosen such that there are cell boundaries between the x-coordinates and y-coordinates of all points respectively. If points
lie on a regular grid, resolution is chosen to fit this grid.
A grid
can also be provided which saves computational effort.
If no index
is given, grid cells are assigned to the nearest point (based on get.knnx
).
If index
, grid
and points
are given, points
are ignored.
If points
are at the same location or so close that they are merged, the associated data of only one point is used.
A SpatialPolygridDataFrame
.
If no data
is given, the returned data consists of one column 'Index' with the indices of the associated points.
proj4string
of points
is kept if available, else the one of grid
is taken.
This function is used to coerce SpatialPointsDataFrame to SpatialPolygridDataFrame.
Kristina B. Helle, kristina.helle@uni-muenster.de
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # prepare
data(SPolygridDF)
regularPoints = coordinates(SPolygridDF)
irregularPoints = regularPoints + runif(12, 0.1)
# grid for regular points
newSPolygrid_reg = points2polygrid(points = regularPoints,
data = data.frame(a = 12:1 * 5))
spplot(newSPolygrid_reg,
sp.layout = list(list("sp.points", regularPoints, col = 3)))
# generate grid for irregular points with given resolution
newSPolygrid_irreg = points2polygrid(points = irregularPoints, tolerance = 0.5)
spplot(newSPolygrid_irreg, sp.layout = list("sp.points", irregularPoints, col = 3))
# with given grid
newSPolygrid_grid = points2polygrid(points = irregularPoints,
grid = GridTopology(c(2,2), c(1,1), c(10,10)))
spplot(newSPolygrid_grid, sp.layout = list("sp.points", irregularPoints, col = 3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.