SpatialLinesMidPoints: Line midpoints

Description Usage Arguments Details Value Author(s) Examples

View source: R/midpoint.R

Description

The function onverts SpatialLinesDataFrame to SpatialPointsDataFrame with points at the midpoints of the line segments.

Usage

1

Arguments

sldf

A SpatialLines or SpatialLinesDataFrame object

Details

The function builds a SpatialPointsDataFrame from the midpoints of Line objects belonging to Lines objects in an object inheriting from a Spatial Lines object. The output data slot contains an index variable showing which Lines object the midpoints belong to.

Value

A SpatialPointsDataFrame object created from the input object.

Author(s)

Jonathan Callahan, modified by Roger Bivand

Examples

1
2
3
4
5
xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
 proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
plot(xx, col="blue")
spdf <- SpatialLinesMidPoints(xx)
plot(spdf, col="orange", add=TRUE)

Example output

Loading required package: sp
Checking rgeos availability: FALSE
 	Note: when rgeos is not available, polygon geometry 	computations in maptools depend on gpclib,
 	which has a restricted licence. It is disabled by default;
 	to enable gpclib, type gpclibPermit()
Warning message:
readShapeLines is deprecated; use rgdal::readOGR or sf::st_read 

maptools documentation built on Sept. 7, 2021, 5:09 p.m.