readShapePoints

0th

Percentile

Read points shape files into SpatialPointsDataFrame objects

The readShapePoints reads data from a points shapefile into a SpatialPointsDataFrame object. The writePointsShape function writes data from a SpatialPointsDataFrame object to a shapefile. Both reading and writing can be carried out for 2D and 3D point coordinates.

Keywords
spatial
Usage
readShapePoints(fn, proj4string = CRS(as.character(NA)), verbose = FALSE, repair=FALSE)
writePointsShape(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
Value

  • a SpatialPointsDataFrame object

Aliases
  • readShapePoints
  • writePointsShape
Examples
library(maptools)
xx <- readShapePoints(system.file("shapes/baltim.shp", package="maptools")[1])
plot(xx)
summary(xx)
xxx <- xx[xx$PRICE < 40,]
tmpfl <- paste(tempdir(), "xxpts", sep="/")
writePointsShape(xxx, tmpfl)
getinfo.shape(paste(tmpfl, ".shp", sep=""))
axx <- readShapePoints(tmpfl)
plot(axx, col="red", add=TRUE)
unlink(paste(tmpfl, ".*", sep=""))
xx <- readShapePoints(system.file("shapes/pointZ.shp", package="maptools")[1])
dimensions(xx)
plot(xx)
summary(xx)
Documentation reproduced from package maptools, version 0.5-14, License: GPL version 2 or later (R and interface code), MIT (shapelib code)

Community examples

Looks like there are no examples yet.