Description Usage Arguments Value Note Author(s) Examples
Uses readOGR in package 'rgdal' to read a river shapefile, and establishes connectivity of segment endpoints based on spatial proximity.
1 2 | line2network(sp = NA, path = ".", layer = NA, tolerance = 100,
reproject = NULL, supplyprojection = NULL)
|
sp |
SpatialLinesDataFrame object. optional. |
path |
File path, default is the current working directory. |
layer |
Name of the shapefile, without the .shp extension. |
tolerance |
Snapping tolerance of segment endpoints to determine connectivity. Default is 100, therefore care should be exercised when working with larger units of distance, such as km. |
reproject |
A valid Proj.4 projection string, if the shapefile is to be re-projected. Re-projection is done using spTransform in package 'sp'. |
supplyprojection |
A valid Proj.4 projection string, if the input shapefile does not have the projection information attached. |
Returns an object of class "rivernetwork"
containing all
spatial and topological information. See rivernetwork-class.
Since distance can only be calculated using projected coordinates,
line2network()
will generate an error if a non-projected input
shapefile is detected. To resolve this, the shapefile can be re-projected
in a GIS environment, or using reproject=
, shown in the second
example below.
Matt Tyers, Joseph Stachelek
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | filepath <- system.file("extdata", package="riverdist")
Gulk_UTM5 <- line2network(path=filepath, layer="Gulk_UTM5")
plot(Gulk_UTM5)
## Reading directly from a SpatialLinesDataFrame object
sp <- rgdal::readOGR(dsn = filepath, layer = "Gulk_UTM5", verbose = FALSE)
Gulk_UTM5 <- line2network(sp)
plot(Gulk_UTM5)
## Re-projecting in Alaska Albers Equal Area projection:
AKalbers <- "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154
+x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"
Gulk_AKalbers <- line2network(path=filepath, layer="Gulk_UTM5", reproject=AKalbers)
plot(Gulk_AKalbers)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.