Skip to content

comparing raster and vector data with Grass/R

4 messages · Schmitt Thierry, Roger Bivand, Jonathan Greenberg +1 more

#
I am struggling to overlay spatialLinesDataFrame and SpatialGridDataFrame. The overlay method doesn't allow me to do so.

As mentioned by matt, I might have a look at starspan. However, I might be interested to have some solution within the Grass/R interface

Thierry
#
On Wed, 7 Mar 2007, Schmitt Thierry wrote:

            
There is no overlay method, you would need to write one, or interpolate 
points along your lines and overlay the resulting point object on the 
raster.
Could I suggest that you try v.to.rast in GRASS, and simply use multiple 
rasters? You may need care with the resolution, but in spearfish:

v.to.rast input=roads output=v_roads use=cat

then in R:

library(spgrass6)
sp <- readRAST6(c("v_roads", "elevation.dem"))
summary(sp)
sp1 <- as(sp, "SpatialPixelsDataFrame")
summary(sp1)
sp2 <- sp1[!is.na(sp1$v_roads),]
summary(sp2)
by(sp2$elevation.dem, sp2$v_roads, summary)

which just preserves the raster cells crossed by roads as defined by 
v.to.rast.

Hope this helps,

Roger

  
    
#
Our primary developer for starspan (I designed the program, but did none of
the coding) has since moved on to bigger and better things, but I would
LOVE to get some help getting starspan cleaned up so it can be a GRASS
add-on.  If anyone is interested, please send me an email about it --
ultimately I'd like to write this up for a short paper in Computers and
Geosciences, and I'd be happy to make anyone who wants to take over the
coding aspect a co-author...

--j

(P.S. Email me at greenberg at ucdavis.edu, I need to update my email on this
listserv)
On 3/7/07 12:33 PM, "Roger Bivand" <Roger.Bivand at nhh.no> wrote:

            

  
    
#
Roger Bivand wrote:
There is an spsample method for lines which returns points, on random or 
regular intervals. You could then overlay these points.

What exactly did you have in mind an overlay function for lines and 
grids would do? In "Geographic information analysis" David O'Sullivan 
and David Unwin suggest that any two types of spatial data can be 
overlaid, leaving finding of examples as an example to the reader. I'm 
still struggling with a few!
--
Edzer