On Fri, 29 May 2009, Felix Andrews wrote:

2009/5/29 Roger Bivand <roger.biv...@nhh.no>:
On Thu, 28 May 2009, brwin...@aol.com wrote:

Good Morning:

I need to construct a set of Thiessen Polygons centered around
approximately 4500 longlat positions in the US.  After searching the R site,
I was going to attempt to use the arealsubPolygons function in the
hydrosanity package.  I am using a Windows system.

When attempting to call the package I get the following error messages
under both R2.8.1 and R2.9.0.
##################################################################

require(hydrosanity)

Loading required package:  hydrosanity
Loading required package: playwith
Loading required package:  lattice
Loading required package: cairoDevice
Error in inDL(x,  as.logical(local), as.logical(now), ...) :
unable to load shared  library
'C:/PROGRA~1/R/R-28~1.1/library/cairoDevice/libs/cairoDevice.dll':
LoadLibrary failure:  The specified module could not be found.


Error: package 'cairoDevice' could not be  loaded
###################################################################
I have tried downloading the package and it's dependencies from  several
locations and get the same errors each time.

Any suggestions with respect to this package or others that I might  use
to
construct my polygons would be appreciated.  I need a set  of polygons
that
cover the entire US county polygon.

The package description does say that it is "under development and should
not be considered stable", seems honest. Look at the code in its URL:

http://code.google.com/p/hydrosanity/source/browse/trunk/R/spatial_functions.R

find the function and its dependencies, load sp first, and probably a matrix
of boundary coordinates for a representation that has a coercion method to
gpc.poly, your point matrix, a vector of IDs, and source the function
locally. That avoids resolving all the dependencies needed for the GUI in
the package, and ought to work. Watch the min.area.pct= argument as small
polygons may go away.

Should work with some tweaking.

I tried

library(sp)
library(tripack)
library(gpclib)
foo <- arealSubPolygons(state.center, IDs = state.name)
class(foo)
[1] "SpatialPolygons"

But I can't seem to plot the result...
spplot(foo)
Error in function (classes, fdef, mtable)  :
 unable to find an inherited method for function "spplot", for
signature "SpatialPolygons"

Well, there isn't a method, because they only exist for Spatial*DataFrame objects for obvious reasons. Just use base graphics plot() methods for the Spatial* classes. I guess that the boundary argument is usually a matrix - does it have to be a single ring, or can it be several rings?

By the way, was there an explanation for the failed cairoDevice dependency? Keeping control of dependencies like those in this package is seriously challenging.

Roger


Note also that you can construct Thiessen / Voronoi Polygons for
plotting with the tileplot function in latticeExtra:

library(latticeExtra)
tileplot(x ~ x * y, state.center, border = "black", points=FALSE)

See the code for panel.voronoi for how it is done
(it has two implementations, based on either tripack or deldir).


Hope that helps
-Felix




--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to