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
comparing raster and vector data with Grass/R
4 messages · Schmitt Thierry, Roger Bivand, Jonathan Greenberg +1 more
On Wed, 7 Mar 2007, Schmitt Thierry wrote:
I am struggling to overlay spatialLinesDataFrame and SpatialGridDataFrame. The overlay method doesn't allow me to do so.
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.
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
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
Thierry
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
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
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:
On Wed, 7 Mar 2007, Schmitt Thierry wrote:
I am struggling to overlay spatialLinesDataFrame and SpatialGridDataFrame. The overlay method doesn't allow me to do so.
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.
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
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
Thierry
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Jonathan A. Greenberg, PhD Postdoctoral Scholar Center for Spatial Technologies and Remote Sensing (CSTARS) University of California, Davis One Shields Avenue The Barn, Room 250N Davis, CA 95616 Cell: 415-794-5043 AIM: jgrn307 MSN: jgrn307 at hotmail.com
Roger Bivand wrote:
On Wed, 7 Mar 2007, Schmitt Thierry wrote:
I am struggling to overlay spatialLinesDataFrame and
SpatialGridDataFrame. The overlay method doesn't allow me to do so.
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.
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