[R-sig-Geo] SpatialLines and SpatialGridDataFrame overlay or transect sampling

Andrew Niccolai andrew.niccolai at yale.edu
Mon Mar 31 23:26:39 CEST 2008

Hi Roger et. al.!

Again, let me start by thanking the Spatial R group for almost 2 years of
fantastic help in my research.  I am currently working on a part of my
puzzle that can be easily done in image processing software such as ENVI but
I am looking for an R solution.  I have a list of lines objects gathered as
a SpatialLines object that "sits" on top of a SpatialGridDataFrame object.
I would like to collect all of the spectral intensity values (or z values)
from the "SpatialGridDataFrame" object that lie along the transect made from
any line of my SpatialLines object.  Here is imaginary code for what I would
like to accomplish

tmp.lines <- Lines(Line(rbind(rank.max2.test[1,1:2], tmp.coords[1,])),
looplen <- nrow(tmp.coords)
for ( i in 2:looplen){
i <- Lines(Line(rbind(rank.max2.test[1,1:2], tmp.coords[i,])),
tmp.lines <- c(tmp.lines, i)
tmp.slines <- SpatialLines(tmp.lines, proj4string = CRS(as.character(NA)))

where rank.max2.test[1,1:2]
[1] 945112.5 859834.5

[1] 945110.6 859848.5

## The above code works great at producing a SpatialLines object with
nrow(tmp.coords) lines

NOW the part that doesn't work
 Transect.values <- overlay(SGDF, tmp.slines[1])

Where SGDF is an object of class SpatialGridDataFrame.

Can this be accomplished as a SpatialLines class (or some polyline general
class) or does the overlay need points?  If I must use points to extract the
SGDF values, is there a way to convert the SpatialLines object into a set of
point coordinates at fixed intervals along the line.  Currently the lines
are only defined as starting and ending coordinates but I would want the
line "points" to occur every 1 meter along the line transect.

Many thanks in advance for any help in this endeavor,

Andrew Niccolai
Doctoral Candidate
Yale University
office (203) 432-5144
cell (860) 402-6079

More information about the R-sig-Geo mailing list