voronoipolygons | R Documentation |
voronoipolygons
Generate Thiesson Polygons from a point data
voronoipolygons
voronoipolygons(x, pts = x@coords, rw = NULL, crs = NULL)
x |
ShapePoints* in PCS |
pts |
Coordinates (x,y) of the points |
rw |
extent |
crs |
projection parameters |
ShapePolygon*
library(rgeos)
library(rSHUD)
n=10
xx = rnorm(n)
yy = rnorm(n)
str = paste('MULTIPOINT(', paste(paste('(', xx, yy, ')'), collapse = ','), ')')
x=readWKT(str)
vx = voronoipolygons(x)
raster::plot(vx, axes=TRUE)
raster::plot(add=TRUE, x, col=2)
#' ====END====
x=1:5
y=1:5
xy=expand.grid(x,y)
vx=voronoipolygons(pts=xy)
plot(vx, axes=TRUE)
points(xy)
#' ====END====
library(rgdal)
library(raster)
library(rgeos)
n=10
xx = rnorm(n)
yy = rnorm(n)
str = paste('MULTIPOINT(', paste(paste('(', xx, yy, ')'), collapse = ','), ')')
x=readWKT(str)
y=readWKT(paste('MULTIPOINT(', paste(paste('(', xx+2, yy+2, ')'), collapse = ','), ')'))
e1 = extent(y)
e2 = extent(x)
rw = c(min(e1[1], e2[1]),
max(e1[2], e2[2]),
min(e1[3], e2[3]),
max(e1[4], e2[4]) ) + c(-1, 1, -1, 1)
vx=voronoipolygons(x=x, rw=rw)
plot(vx); plot(add=TRUE, x, col=2); plot(add=TRUE, y, col=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.