Learn R Programming

rivnet (version 0.6.0)

contour_to_shapefile: Export catchment contour as shapefile

Description

Export catchment contour as shapefile.

Usage

contour_to_shapefile(river, filename,  
                    EPSG = NULL, ...)

Value

No output is produced. This function is used for its side effetcs.

Arguments

river

river object.

filename

Character. Output file name. It must contain the ".shp" extension.

EPSG

EPSG code. Default is NULL, which does not produce a .prj file (i.e., the shapefile does not contain projection information).

...

Additional arguments to be passed to writeVector (e.g., overwrite = TRUE allows overwriting an existing shapefile).

See Also

Examples

Run this code
if (FALSE) { # interactive() && traudem::can_register_taudem()
library(terra) # to use "vect"
fp <- system.file("extdata/wigger.tif", package="rivnet")
river <- extract_river(outlet=c(637478,237413), DEM=fp)

tmpname <- paste0(tempfile(), ".shp")
contour_to_shapefile(river, tmpname, overwrite = TRUE)

# read output
vv <- vect(tmpname)
vv
plot(vv)

# \donttest{
# export contour shapefile for multiple catchments
river <- extract_river(outlet=data.frame(x=c(637478,629532),y=c(237413,233782)),
                   EPSG=21781, #CH1903/LV03 coordinate system
                   ext=c(6.2e5,6.6e5,2e5,2.5e5),
                   z=8)
				   
contour_to_shapefile(river, tmpname, overwrite = TRUE)
vv <- vect(tmpname)
vv
plot(vv)

# add projection 
contour_to_shapefile(river, tmpname, 
					EPSG = 21781, 
					overwrite = TRUE)
vv <- vect(tmpname)
vv					
# }

}

Run the code above in your browser using DataLab