rasterise_stream {rdwplus}R Documentation

Turn a shapefile of stream edges into a raster

Description

Given a shapefile of lines representing the channels of a stream network, this function will return a rasterised version of the shapefile. The raster will have the parameters of the current GRASS mapset.

Usage

rasterise_stream(streams, out, overwrite = FALSE, max_memory = 300, ...)

Arguments

streams

A file name for a shapefile of stream edges in the current GRASS mapset.

out

The filename of the output.

overwrite

A logical indicating whether the output is allowed to overwrite existing files. Defaults to FALSE.

max_memory

Max memory used in memory swap mode (MB). Defaults to 300.

...

Additional arguments to v.to.rast.

Value

Nothing. A file will be written to out. Note that out can be a full file path to any location in your file system. A raster with the name basename(out) will be written to the current GRASS mapset.

Examples

# Will only run if GRASS is running
if(check_running()){
# Load data set
dem <- system.file("extdata", "dem.tif", package = "rdwplus")
stream_shp <- system.file("extdata", "streams.shp", package = "rdwplus")

# Set environment parameters and import data to GRASS
set_envir(dem)
vector_to_mapset(vectors = stream_shp)

# Create rasterised stream
rasterise_stream("streams", "streams_rast.tif", overwrite = TRUE)

# Plot
plot_GRASS("streams_rast.tif")

}

[Package rdwplus version 1.0.0 Index]