Help with Voronoi Tesselation
Does this help at all? http://www.carsonfarmer.com/?p=455 Carson
On Fri, May 14, 2010 at 1:39 AM, Josef Fruehwald <jofrhwld at gmail.com> wrote:
Hi All,
I'm somewhat of a novice at doing spatial analysis in R, so forgive me if my
question is obvious, or misposted.
I have a number of points located within the United States. My goal is to
compute the voronoi tessellation, bounded by the borders of the US. I would
like to eventually format this as a dataframe of coordinates with a grouping
ID column so that I can plot the polygons in ggplot2.
Here's what I've got so far.
cities <- structure(list(CitState = c("SiouxFalls SD", "Rockford IL",
"Kenosha WI",
"Duluth MN", "SiouxCity IA", "CedarRapids IA", "NewYork NY"),
? ?Latitude = c(43.54599, 42.265973, 42.577791, 46.779135, 42.489678,
? ?41.976662, 40.756054), Longitude = c(-96.731291, -89.086667,
? ?-87.822644, -92.108243, -96.404948, -91.673155, -73.986951
? ?)), .Names = c("CitState", "Latitude", "Longitude"), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 267L), class = "data.frame")
library(maps)
library(spatstat)
us <- data.frame(map("usa", regions = "main",plot = F)[c("x","y")])
manhattan <- data.frame(map("usa", regions = "manhattan",plot =
F)[c("x","y")])
spatstat.options(checkpolygons = FALSE)
us.win <- owin(poly = list(list(x = us$x, y = us$y),list(x = manhattan$x,y =
manhattan$y)))
us.ppp <- ppp(cities$Longitude, cities$Latitude, window = us.win)
But, if I use dirichlet() on us.ppp, it gives me back a pixel array. If I
use deldir() on us.ppp, the boundaries of the tesselations don't seem to be
constrained by the US borders, and I can't figure out how to extract the
polygons from the object.
plot(dirichlet(us.ppp))
##
map("usa")
plot(deldir(us.ppp), wlines = "tess",add = T)
If I could extract from some object, a list of polygons, I could probably
get the rest done myself.
Thanks in advance!
-Joe
? ? ? ?[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Carson J. Q. Farmer ISSP Doctoral Fellow National Centre for Geocomputation National University of Ireland, Maynooth, http://www.carsonfarmer.com/