maptools (version 0.7-37)

write.linelistShape: Write a arc-type shapefile

Description

The function calls code from shapelib to write an arc-type shapefile from a list of matrices of line coordinates with no NAs.

Usage

write.linelistShape(linelist, df, file, factor2char = TRUE,
 strictFilename=FALSE, max_nchar=254)

Arguments

linelist
a list of matrices of line 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 an arc-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.pointShape, write.dbf

Examples

Run this code
x <- 10 * 1:nrow(volcano)
y <- 10 * 1:ncol(volcano)
line.list <- contourLines(x, y, volcano)
vol.levels <- data.frame(alt=sapply(line.list, function(x) x[[1]]))
vol.ll <- lapply(line.list, function(x) cbind(x$x, x$y))
for (i in seq(along=vol.ll)) {
  attr(vol.ll[[i]], "nParts") <- as.integer(1)
  attr(vol.ll[[i]], "pstart") <- list(as.integer(1),
    as.integer(nrow(vol.ll[[i]])))
}
tmpshp <- paste(tempdir(), "volcano", sep="/")
write.linelistShape(vol.ll, vol.levels, file=tmpshp)
try1 <- readShapeLines(tmpshp)
plot(try1)

Run the code above in your browser using DataCamp Workspace