[R-sig-Geo] comparing raster and vector data with Grass/R
Roger Bivand
Roger.Bivand at nhh.no
Wed Mar 7 21:33:43 CET 2007
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
More information about the R-sig-Geo
mailing list