readShapeLines

0th

Percentile

Read arc shape files into SpatialLinesDataFrame objects

The readShapeLines function reads data from an arc/line shapefile into a SpatialLinesDataFrame object; the shapefile may be of type polygon, but for just plotting for example coastlines, a SpatialLines object is sufficient. The writeLinesShape function writes data from a SpatialLinesDataFrame object to a shapefile.

Keywords
spatial
Usage
readShapeLines(fn, proj4string=CRS(as.character(NA)), verbose=FALSE, repair=FALSE)
writeLinesShape(x, fn, factor2char = TRUE)
Arguments
fn
shapefile layer name, without extension
proj4string
Object of class CRS; holding a valid proj4 string
verbose
default TRUE - report type of shapefile and number of shapes
repair
default FALSE: some shapefiles provided by Geolytics Inc. have values of object sizes stored in the *.shx index file that are eight bytes too large, leading the function to try to read past the end of file. If repair=TRUE, an attempt is made to repair the
x
a SpatialLinesDataFrame object
factor2char
logical, default TRUE, convert factor columns to character
Details

The shpID values of the shapefile will be used as Lines ID values; when writing shapefiles, the object data slot rownames are added to the DBF file as column SL_ID.

Value

  • a SpatialLinesDataFrame object

Aliases
  • readShapeLines
  • writeLinesShape
Examples
xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1], proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
plot(xx, col="blue")
summary(xx)
xxx <- xx[xx$LENGTH > 30000,]
plot(xxx, col="red", add=TRUE)
tmpfl <- paste(tempdir(), "xxline", sep="/")
writeLinesShape(xxx, tmpfl)
getinfo.shape(paste(tmpfl, ".shp", sep=""))
axx <- readShapeLines(tmpfl, proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))
plot(xxx, col="black", lwd=4)
plot(axx, col="yellow", lwd=1, add=TRUE)
unlink(paste(tmpfl, ".*", sep=""))
xx <- readShapeLines(system.file("shapes/sids.shp", package="maptools")[1], proj4string=CRS("+proj=longlat +datum=NAD27"))
plot(xx, col="blue")
Documentation reproduced from package maptools, version 0.6-13, License: GPL version 2 or later (R and interface code), MIT (shapelib code)

Community examples

Looks like there are no examples yet.