raster (version 1.0.4)

linesToRaster: Lines to raster

Description

Lines to raster conversion. Lines are raserized.

Usage

linesToRaster(spLines, raster, field=0, filename="", updateRaster=FALSE, updateValue="NA", ...)

Arguments

spLines
SpatialLines or a SpatialLinesDataFrame object (sp package)
raster
RasterLayer object
field
The index of the column in the SpatialLinesDataFrame to be transfered to the RasterLayer (or the name of that field)
filename
Character. output filename
updateRaster
logical. If TRUE the values of the input RasterLayer are updated where the polygons overlap cells
updateValue
character. Select cells to be updated (if updateRaster == TRUE) by their current values. Either 'all', 'NA', '!NA', or 'zero'
...
additional arguments. See Details.

Details

For SpatialLines, the 'field' argument is ignored. The line index is used as attribute. The following additional arguments can be passed, to replace default values for this function rll{ overwrite Logical. If TRUE, "filename" will be overwritten if it exists format Character. Output file type. See writeRaster datatype Character. Output data type. See dataType progress Character. Valid values are "text", "tcltk", "windows" (on that platform only) and "" }

See Also

polygonsToRaster, pointsToRaster

Examples

Run this code
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") ))

r <- raster(ncols=90, nrows=45)
r <- linesToRaster(lines, r)
#plot(r)
#plot(lines, add=TRUE)

Run the code above in your browser using DataLab