Learn R Programming

raster (version 1.5-16)

lineValues: Extract values from a RasterLayer by lines

Description

This method returns the values of the cells of a Raster* object that are crossed by a line. .

Usage

lineValues(lns, x, ...)

Arguments

lns
SpatialLines* object
x
Raster* object
...
additional arguments (none implemented)

Value

  • A list as long as the number of lines in lns

See Also

polygonValues, cellValues, xyValues, getValues, SpatialLines

Examples

Run this code
r <- raster(nrow=18, ncol=9)
r[] <- 1:ncell(r)

cds1 <- rbind(c(-50,0), c(0,60), c(40,5), c(15,-45), c(-10,-25))
cds2 <- rbind(c(80,20), c(140,60), c(160,0), c(140,-55))
cds3 <- rbind(c(-180,-20), c(-140,-60), c(-60,-20), c(-140,55))
lines <- SpatialLines(list(Lines(list(Line(cds1)), "1"), Lines(list(Line(cds2)), "2"), Lines(list(Line(cds3)), "3") ))

lineValues(lines, r)

Run the code above in your browser using DataLab