Hi All,
My goal is to create a Voronoi Tessellation which is bounded by the
borders of the United States and Canada, then export the polygons to a
dataframe for plotting in ggplot2. After much futzing around with
spatstat and sp, I've given up on figuring out how to do this the
right way. I got this 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)
us.d <- dirichlet(us.ppp)
Extracting polygons from the output of dirichlet() seems hopeless.
So, I'm wondering if I can fake it. I can create a voronoi
tessellation from my data with deldir(), and get that into the right
shape for plotting. I'm wondering if there is some way to plot the
inverse of the us as a polygon, plotted over the voronoi tessellation,
making it appear to be bounded by the borders of the us.
us$ID <- 1
ggplot(us, aes(x,y)) + geom_polygon(aes(group = ID))
-Joe
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example:
http://gist.github.com/270442
To post: email
ggp...@googlegroups.com
To unsubscribe: email
ggplot2+u...@googlegroups.com
More options:
http://groups.google.com/group/ggplot2