Description Usage Arguments Value Examples
Create a shapefile/spatialPoints of the Voronoi diagram of given points.
1 | voronoiShapefile(lon, lat, shp)
|
lon |
A vector of longitudes |
lat |
A vector of latitudes |
shp |
A |
Returns a SpatialPolygons
of the voronoi diagram of the points, intersected with the given shapefile.
1 2 3 4 5 6 7 8 9 10 11 12 | # Get a shapefile of US States:
file <- "http://www2.census.gov/geo/tiger/GENZ2015/shp/cb_2015_us_state_20m.zip"
download.file(file, "states.zip")
unzip("states.zip")
shp <- rgdal::readOGR(".", "cb_2015_us_state_20m")
shp <- shp[shp@data$STATEFP != "02", ]
shp <- shp[shp@data$STATEFP != "15", ]
shp <- shp[shp@data$STATEFP != "72", ]
shp <- sp::spTransform(shp, sp::CRS("+init=epsg:26978"))
crds <- sp::coordinates(shp)
voronoi <- voronoiShapefile(crds[, 1], crds[, 2], shp = shp)
plot(voronoi)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.