Geoscience Reference
In-Depth Information
So far, many of the predicates and operators are applied to all member geometries, but work
is progressing, spurred by clear needs demonstrated by Altman and McDonald (2011) in the
BARD - Better Automated ReDistricting - package (Altman 2011) for finding reduced sets of
candidate pairs of contiguous geometries. Using the GEOS Sort-Tile-Recursive (STR) tree, we
build a tree of geometry envelopes (bounding boxes) and then query with the same envelopes with
gUnarySTRtreeQuery , passing the output candidate neighbours to the poly2nb function in
the spdep package:
> la_blks <- readOGR(".", "tgr06037blk00")
> library(spdep)
> library(rgeos)
> system.time(nb <- poly2nb(la_blks,
+ foundInBox = gUnarySTRtreeQuery(la_blks)))
user system elapsed
14.723 0.111 15.167
> nb
Neighbour list object:
Number of regions: 89614
Number of nonzero links: 623984
Percentage nonzero weights: 0.007770013
Average number of links: 6.963019
Finding the neighbours is very much faster than using the internal brute-force approach for finding
overlapping bounding boxes in poly2nb , and working with all the census blocks in Los Angeles
becomes feasible. The new pycno package by Brunsdon (2011) also uses rgeos internally for
pycnophylactic interpolation; here we smooth the leukaemia rate from the 8 county New York data
set. In addition, for display, we use gBuffe r from rgeos to add a 10 km buffer around supposed
point source pollution sites shown in Figure 14.4:
> library(pycno)
> NY$eZ <- (1000 * (NY$TRACTCAS+1))/NY$POP8
> NYp <- pycno(NY, pops=NY$e, celldim=500)
> TCE <- readOGR(dsn = td, layer = "TCE")
> TCE10k <- gBuffer(TCE, width=10000)
Work on rgeos is continuing actively, and improvements in stability and speed can be expected
as more users report their experiences. A specific issue raised in interfacing GEOS (and OGR)
is that use is made of the OGC SFS geometry specification, but the SpatialPolygons class
in sp is more like a shapefile, without clear assignation of interior rings to exterior rings. Had the
SpatialPolygons class in sp been designed a little later, it might well have followed the OGC
SFS geometry specification, but this in turn would have led to additional difficulties for users with-
out conforming data.
14.4.4 g eograPhic r eSourceS a nalySiS S uPPort S ySteM : spgrass6
The original interface package between GRASS 5 and R, GRASS , written and released on
CRAN in 2000, was tight-coupled, including a local copy of the core GRASS library, so that
GRASS database files could be read into and written from R (Bivand 2000, Bivand and Neteler
2000). Figure 14.5 shows how the R session was started from the command prompt in a running
GRASS session and location, giving ready access to GRASS and other commands through sys-
tem and to GRASS itself through calls to compiled C functions. This had the advantage of speed,
but the weakness of containing a modified fork of the core GRASS library, modified to use the
Search WWH ::




Custom Search