Learn R Programming

maptools (version 1.0-2)

readShapePoints: Read points shape files into SpatialPointsDataFrame objects

Description

The use of this function is deprecated and it is not being maintained. Use rgdal::readOGR() or sf::st_read() instead - both of these read the coordinate reference system from the input file, while this deprecated function does not.For writing, use rgdal::writeOGR() or sf::st_write() instead.

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. Note DBF file restrictions in write.dbf.

Usage

readShapePoints(fn, proj4string = CRS(as.character(NA)), verbose = FALSE,
 repair=FALSE)
writePointsShape(x, fn, factor2char = TRUE, max_nchar=254)

Arguments

fn

shapefile layer name, when writing omitting the extensions *.shp, *.shx and *.dbf, which are added in the function

proj4string

Object of class CRS; holding a valid proj4 string

verbose

default FALSE - 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 internal values, permitting such files to be read.

x

a SpatialPointsDataFrame object

factor2char

logical, default TRUE, convert factor columns to character

max_nchar

default 254, may be set to a higher limit and passed through to the DBF writer, please see Details in write.dbf

Value

a SpatialPointsDataFrame object

See Also

write.dbf

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab