Learn R Programming

terra (version 1.9-46)

topology: Vector topology methods

Description

makeNodes create nodes on lines

mergeLines connect lines to form polygons

removeDupNodes removes duplicate nodes in geometries and optionally rounds the coordinates

emptyGeoms returns the indices of empty (null) geometries. is.na also checks if any of the coordinates is NA.

snap makes boundaries of geometries identical if they are very close to each other. The tolerance is expressed in the coordinate reference system's units: meters (or feet, etc.) for projected data, and degrees for lon/lat data. To snap lon/lat geometries with a tolerance expressed in meters, project the data to a metric CRS first with project, snap, then project back. simplifyGeom uses the same convention.

Usage

# S4 method for SpatVector
mergeLines(x)
# S4 method for SpatVector
snap(x, y=NULL, tolerance)
# S4 method for SpatVector
removeDupNodes(x, digits = -1)
# S4 method for SpatVector
makeNodes(x)

Value

SpatVector

Arguments

x

SpatVector of lines or polygons

y

SpatVector of lines or polygons to snap to. If NULL snapping is to the other geometries in x

tolerance

numeric. Snapping tolerance, expressed in the units of the CRS of x (i.e. meters or feet for projected data, degrees for lon/lat data). One degree of latitude is approximately 111 km.

digits

numeric. Number of digits used in rounding. Ignored if < 0

See Also

sharedPaths, gaps, simplifyGeom, forceCCW, fillHoles

Examples

Run this code
p1 <- as.polygons(ext(0,1,0,1))
p2 <- as.polygons(ext(1.1,2,0,1))

p <- rbind(p1, p2)

y <- snap(p, tol=.15)
plot(p, lwd=3, col="light gray")
lines(y, col="red", lwd=2)

Run the code above in your browser using DataLab