shapefile_input() creates or imports a shapefile and optionally converts
it to an sf object. It can also cast POLYGON or MULTIPOLYGON geometries
to MULTILINESTRING if required.
shapefile_export() exports an object (sf or SpatVector) to a file.
shapefile_view() is a simple wrapper around mapview() to plot a shapefile.
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")),
...
)
shapefile_input() returns an object of class sf (default) representing
the imported shapefile.
shapefile_export() returns a NULL object.
shapefile_view() returns an object of class mapview.
For shapefile_input(), character (filename), or an object that can be
coerced to a SpatVector, such as an sf (simple features) object. See
terra::vect() for more details.
For shapefile_export(), a SpatVector or an sf object to be exported as
a shapefile.
Logical value indicating whether to print information about the
imported shapefile (default is TRUE).
Logical value indicating whether to convert the imported
shapefile to an sf object (default is TRUE).
Logical value indicating whether to cast polygon geometries
to MULTILINESTRING geometries (default is FALSE).
Additional arguments to be passed to terra::vect()
(shapefile_input()), terra::writeVector() (shapefile_export()) or
mapview::mapview() (shapefile_view()).
The path to the output shapefile.
The attribute to be shown in the color key. It must be a
variable present in shapefile.
A character string specifying whether to visualize the shapefile
as "shape" or as "centroid". Partial matching is allowed. If set to
"centroid", the function will convert the shapefile's geometry to
centroids before displaying. Defaults to "shape".
The color palette to represent attribute.
if(interactive()){
library(pliman)
shp <- system.file("ex/lux.shp", package="terra")
shp_file <- shapefile_input(shp, as_sf = FALSE)
shapefile_view(shp_file)
}
Run the code above in your browser using DataLab