maptools (version 0.8-4)

write.pointShape: Write a point-type shapefile

Description

The function calls code from shapelib to write a point-type shapefile.

Usage

write.pointShape(coordinates, df, file, factor2char = TRUE,
 strictFilename=FALSE, max_nchar=254)

Arguments

coordinates
a 2-column numeric matrix of coordinates
df
a data frame object
file
a file name of maximum 8 chararacters, numbers or the underscore symbol to be written, omitting the extensions *.shp, *.shx and *.dbf, which are added in the function
factor2char
logical, default TRUE, convert factor columns to character
strictFilename
if TRUE, impose file basename length limit of 8 characters
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

  • no return value.

Details

The function calls code from shapelib to write a point-type shapefile (both the geometry file with a *.shp extension, the index file with a *.shx extension, and the database file with a *.dbf extension - see write.dbf for details of the data frame export within this function.

References

http://shapelib.maptools.org/

See Also

write.dbf

Examples

Run this code
balt_orig <- readShapePoints(system.file("shapes/baltim.shp", package="maptools")[1])
plot(balt_orig)
balt_cheap <- balt_orig[balt_orig$PRICE < 40,]
file <- tempfile("")
write.pointShape(coordinates=coordinates(balt_cheap),
 df=as(balt_cheap, "data.frame"), file)
getinfo.shape(paste(file, ".shp", sep=""))
balt_new <- readShapePoints(paste(file, ".shp", sep=""))
plot(balt_new, col="red", pch=16, add=TRUE)

Run the code above in your browser using DataCamp Workspace