voronoiShapefile: Create a shapefile/spatialPoints of the Voronoi diagram of...

Description Usage Arguments Value Examples

Description

Create a shapefile/spatialPoints of the Voronoi diagram of given points.

Usage

1
voronoiShapefile(lon, lat, shp)

Arguments

lon

A vector of longitudes

lat

A vector of latitudes

shp

A SpatialPolygonsDataFrame surrounding where the points lie.

Value

Returns a SpatialPolygons of the voronoi diagram of the points, intersected with the given shapefile.

Examples

 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)

walshc/voronoi documentation built on May 17, 2019, 8:46 p.m.