[R-sig-Geo] Help with Voronoi Tesselation

Adrian.Baddeley at csiro.au Adrian.Baddeley at csiro.au
Mon May 17 07:36:55 CEST 2010


Josef Fruehwald <jofrhwld at gmail.com> writes: 

> 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
  [ ...]
> But, if I use dirichlet() on us.ppp, it gives me back a pixel array.

This is a query about the 'spatstat' package. 

You want the software to clip the Dirichlet polygons to the USA boundary. Polygon computations in spatstat currently depend on the package 'gpclib'. This package has a restrictive licence, so it is turned off by default, and you get a pixel image instead.

To enable polygon computations, type
           spatstat.options(gpclib=TRUE)
Please type licence.polygons() for more information about the licence conditions. 

If the licence conditions do not allow you to use gpclib, then I suggest you replace the USA boundary by a rectangle. Then dirichlet() will give a list of polygons, which you can extract and deal with yourself.

Adrian Baddeley

.............................. Full message ..............................................

> 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.

> library(maps)
> library(spatstat)
  [...]
> 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.


More information about the R-sig-Geo mailing list