read.shape {maptools}R Documentation

Read shapefile into Map object

Description

Read shapefile into Map object; the file should be given including its ".shp" extension, and the function will reconstruct the names of the database (dbf) file and the index (shx) file from these.

Usage

read.shape(filen, dbf.data = TRUE, verbose=TRUE, repair=FALSE)
getinfo.shape(filen)
## S3 method for class 'shapehead':
print(x, ...)

Arguments

filen name of file with *.shp extension
dbf.data read DBF data together with shapes, default TRUE
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 internal values, permitting such files to be read.
x a shapehead list as returned by getinfo.shape
... other arguments passed to print

Details

The function calls code from shapelib to read shapefiles, a file format used by ESRI GIS software among others

Value

read.shape() returns either a list of shapes of class ShapeList, or if dbf.data = TRUE a Map object with:

Shapes a list of shapes of class ShapeList; both the individual shapes and the list have attributes
att.data a data frame of data from the associated DBF file; note that the field names are adjusted to use in R using make.names(), and so will permit the underscore character from R release 1.9.0.

Author(s)

Nicholas J. Lewin-Koh, modified by Roger Bivand Roger.Bivand@nhh.no; shapelib by Frank Warmerdam

References

http://shapelib.maptools.org/

See Also

plot.Map, read.dbf

Examples

x <- read.shape(system.file("shapes/sids.shp", package="maptools")[1])
length(x$Shapes)
unlist(lapply(x$att.data, class))
str(getinfo.shape(system.file("shapes/fylk-val.shp", package="maptools")[1]))

[Package maptools version 0.6-9 Index]