[R-sig-Geo] Problems loading hydrosanity package
Felix Andrews
felix at nfrac.org
Sat May 30 10:33:00 CEST 2009
2009/5/29 Roger Bivand <Roger.Bivand at nhh.no>:
> On Fri, 29 May 2009, Felix Andrews wrote:
>
>> 2009/5/29 Roger Bivand <Roger.Bivand at nhh.no>:
>>>
>>> On Thu, 28 May 2009, BRWIN338 at 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)
Sorry, I forgot the crucial step of sourcing the function -- as an
alternative to installing the whole package, with its dependencies on
RGtk2 etc --:
source("http://hydrosanity.googlecode.com/svn/trunk/R/spatial_functions.R")
>> foo <- arealSubPolygons(state.center, IDs = state.name)
>> class(foo)
>> [1] "SpatialPolygons"
ok, try
with(state.center, {
plot(foo, xlim=range(x), ylim = range(y))
text(x, y, state.abb) })
>>
>> 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.
Those reasons are not obvious to me: I prefer to use Lattice graphics
rather than base graphics, even if I do not need to use conditioning.
The Lattice system is object-based and very flexible; e.g. one can
concatenate or overlay Lattice plot panels using the tools in the
latticeExtra package.
> I guess that the boundary argument is usually a matrix -
> does it have to be a single ring, or can it be several rings?
Yes, you can use a matrix like
boundary = coordinates(myPolygon) (from an sp Polygon class)
But in theory you can supply anything that can be converted with
as(boundary, "gpc.poly")
It should be possible to specify multiple polygons that way; check the
gpclib package.
>
> By the way, was there an explanation for the failed cairoDevice dependency?
> Keeping control of dependencies like those in this package is seriously
> challenging.
Yes, the error message indicated that the cairoDevice DLL was missing.
The most likely cause of that is that the GTK+ libraries have not been
installed. Installation instructions are available at
http://hydrosanity.googlecode.com/
The comment about the package being unstable/incomplete is certainly
true, and it has not been actively maintained for the last year or so.
>
> 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.Bivand at nhh.no
>
>
--
Felix Andrews / 安福立
Post-Doctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 1670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
--
http://www.neurofractal.org/felix/
More information about the R-sig-Geo
mailing list