Learn R Programming

maptools (version 1.1-8)

SpatialLinesMidPoints: Line midpoints

Description

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

Usage

SpatialLinesMidPoints(sldf)

Value

A SpatialPointsDataFrame object created from the input object.

Arguments

sldf

A SpatialLines or SpatialLinesDataFrame object

Author

Jonathan Callahan, modified by Roger Bivand

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab