maptools (version 0.5-11)

readShapePoints: Read points shape files into SpatialPointsDataFrame objects

Description

The readShapePoints reads data from a points shapefile into a SpatialPointsDataFrame object. The writePointsShape function writes data from a SpatialPointsDataFrame object to a shapefile.

Usage

readShapePoints(fn, proj4string = CRS(as.character(NA)), verbose = 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
x
a SpatialLinesDataFrame object
factor2char
logical, default TRUE, convert factor columns to character

Value

  • a SpatialPointsDataFrame object

Examples

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

Run the code above in your browser using DataLab