# 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
set_envir(dem)
vector_to_mapset(vectors = stream_shp)
# Create binary stream
out_name <- paste0(tempdir(), "/streams_rast.tif")
rasterise_stream("streams", out_name, overwrite = TRUE)
reclassify_streams("streams_rast.tif", "streams_binary.tif", out_type = "binary", overwrite = TRUE)
reclassify_streams("streams_rast.tif", "streams_unary.tif", out_type = "unary", overwrite = TRUE)
reclassify_streams("streams_rast.tif", "streams_none.tif", out_type = "none", overwrite = TRUE)
# Plot
plot_GRASS("streams_rast.tif", col = topo.colors(2), main = "Rasterized Streams")
plot_GRASS("streams_binary.tif", col = topo.colors(2), main = "Binary Streams")
plot_GRASS("streams_unary.tif", col = topo.colors(2), main = "Unary Streams")
plot_GRASS("streams_none.tif", col = topo.colors(2), main = "Null (none) Streams")
}
Run the code above in your browser using DataLab