write_shape: write_shape

Description Usage Arguments Examples

View source: R/write_shape.R

Description

Wrapper on sf::st_write for writing an sf or sp object to disk as an ESRI shapefile

Usage

1
2
write_shape(out_obj, out_file, overwrite = FALSE, verbose = FALSE,
  encoding = "UTF-8", create_dir = FALSE, ...)

Arguments

out_obj

character object to be written to the shapefile. Must be a valid *sp or sf object

out_file

character output file name

overwrite

logical if TRUE, output file will be overwritten oif existing, Default: FALSE

verbose

logical if TRUE, provide messages on processing, Default: TRUE

encoding

character encoding to be used to write the DBF of the shapefile, Default: "UTF-8"

create_dir

logical, if TRUE and the folder of out_file doesn't exist, then the full folder tree up to out_file is created, Default: FALSE (use with caution !)

...

any other arguments to be passed to sf::st_write

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
# build a spatialpoints data frame
pts                <- cbind(1:5, 1:5)
dimnames(pts)[[1]] <- letters[1:5]
df                 <-  data.frame(a = 1:5)
row.names(df)      <- letters[5:1]
points             <- sp::SpatialPointsDataFrame(pts, df, match.ID = TRUE)

# Save it to a shape file
out_file  = tempfile(pattern = "test", tmpdir = tempdir(), fileext = ".shp")
mysp_object = points
write_shape(mysp_object, out_file, overwrite = TRUE)

## End(Not run)

IREA-CNR-MI/sprawl documentation built on Aug. 6, 2017, 12:56 p.m.