utils_shapefile {pliman} | R Documentation |
Import/export shapefiles.
Description
-
shapefile_input()
creates or imports a shapefile and optionally converts it to ansf
object. It can also castPOLYGON
orMULTIPOLYGON
geometries toMULTILINESTRING
if required. -
shapefile_export()
exports an object (sf
orSpatVector
) to a file. -
shapefile_view()
is a simple wrapper aroundmapview()
to plot a shapefile.
Usage
shapefile_input(
shapefile,
info = TRUE,
as_sf = TRUE,
multilinestring = FALSE,
...
)
shapefile_export(shapefile, filename, ...)
shapefile_view(
shapefile,
attribute = NULL,
type = c("shape", "centroid"),
color_regions = custom_palette(c("red", "yellow", "forestgreen")),
...
)
Arguments
shapefile |
For For |
info |
Logical value indicating whether to print information about the
imported shapefile (default is |
as_sf |
Logical value indicating whether to convert the imported
shapefile to an |
multilinestring |
Logical value indicating whether to cast polygon geometries
to |
... |
Additional arguments to be passed to |
filename |
The path to the output shapefile. |
attribute |
The attribute to be shown in the color key. It must be a
variable present in |
type |
A character string specifying whether to visualize the shapefile
as |
color_regions |
The color palette to represent |
Value
-
shapefile_input()
returns an object of classsf
(default) representing the imported shapefile. -
shapefile_export()
returns aNULL
object. -
shapefile_view()
returns an object of classmapview
.
Examples
if(interactive()){
library(pliman)
shp <- system.file("ex/lux.shp", package="terra")
shp_file <- shapefile_input(shp, as_sf = FALSE)
shapefile_view(shp_file)
}