Bạn chưa cấp cho chúng tôi quyền truy cập vào dữ liệu của mình, nhưng đây là ví dụ cho các điểm đại diện cho các thành phố trên thế giới, sử dụng phương pháp được Carson Farmer mô tả trên his blog. Hy vọng rằng nó sẽ giúp bạn bắt đầu ...
# Carson's Voronoi polygons function
voronoipolygons <- function(x) {
require(deldir)
require(sp)
if (.hasSlot(x, 'coords')) {
crds <- [email protected]
} else crds <- x
z <- deldir(crds[,1], crds[,2])
w <- tile.list(z)
polys <- vector(mode='list', length=length(w))
for (i in seq(along=polys)) {
pcrds <- cbind(w[[i]]$x, w[[i]]$y)
pcrds <- rbind(pcrds, pcrds[1,])
polys[[i]] <- Polygons(list(Polygon(pcrds)), ID=as.character(i))
}
SP <- SpatialPolygons(polys)
voronoi <- SpatialPolygonsDataFrame(SP, data=data.frame(x=crds[,1],
y=crds[,2], row.names=sapply(slot(SP, 'polygons'),
function(x) slot(x, 'ID'))))
}
Ví dụ 1: Input là một SpatialPointsDataFrame:
# Read in a point shapefile to be converted to a Voronoi diagram
library(rgdal)
dsn <- system.file("vectors", package = "rgdal")[1]
cities <- readOGR(dsn=dsn, layer="cities")
v <- voronoipolygons(cities)
plot(v)

Ví dụ 2: Input là vectơ của x, y tọa độ:
dat <- data.frame(x=runif(100), y=runif(100))
v2 <- voronoipolygons(dat)
plot(v2)

'install.packages ("sos"); thư viện ("sos"); findFn ("thiessen") ' –
Tôi đang sử dụng ArcGIS cho cùng một lúc ... – user2760