Skip to content

Problems loading hydrosanity package

5 messages · BRWIN338 at aol.com, Felix Andrews, Roger Bivand

#
On Thu, 28 May 2009, BRWIN338 at aol.com wrote:

            
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.

Roger

  
    
#
2009/5/29 Roger Bivand <Roger.Bivand at nhh.no>:
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"

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


-- 
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
#
On Fri, 29 May 2009, Felix Andrews wrote:

            
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

  
    
1 day later
#
2009/5/29 Roger Bivand <Roger.Bivand at nhh.no>:
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")
ok, try

with(state.center, {
  plot(foo, xlim=range(x), ylim = range(y))
  text(x, y, state.abb) })
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.
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.
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.
-- 
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