g_simplify()
computes a simplified geometry. By default, it simplifies
the input geometries while preserving topology (see Details). Wrapper of
OGR_G_Simplify()
/ OGR_G_SimplifyPreserveTopology()
in the GDAL API
(GEOS via GDAL headers).
Usage
g_simplify(
geom,
tolerance,
preserve_topology = TRUE,
as_wkb = TRUE,
as_iso = FALSE,
byte_order = "LSB",
quiet = FALSE
)
Arguments
- geom
Either a raw vector of WKB or list of raw vectors, or a character vector containing one or more WKT strings.
- tolerance
Numeric value of the simplification tolerance, as distance in units of the input
geom
. Simplification removes vertices which are within the tolerance distance of the simplified linework (as long as topology is preserved whenpreserve_topology = TRUE
).- preserve_topology
Logical value,
TRUE
to simplify geometries while preserving topology (the default). Setting toFALSE
simplifies geometries using the standard Douglas-Peucker algorithm which is significantly faster (see Details).- as_wkb
Logical value,
TRUE
to return the output geometry in WKB format (the default), orFALSE
to return as WKT.- as_iso
Logical value,
TRUE
to export as ISO WKB/WKT (ISO 13249 SQL/MM Part 3), orFALSE
(the default) to export as "Extended WKB/WKT".- byte_order
Character string specifying the byte order when output is WKB. One of
"LSB"
(the default) or"MSB"
(uncommon).- quiet
Logical value,
TRUE
to suppress warnings. Defaults toFALSE
.
Value
A polygon as WKB raw vector or WKT string, or a list/character vector of
polygons as WKB/WKT with length equal to the number of input geometries.
NA
is returned with a warning if WKB input cannot be converted into an
OGR geometry object, or if an error occurs in the call to the underlying
OGR API.
Details
Definitions of these operations are given in the GEOS documentation (https://libgeos.org/doxygen/), which are copied here (GEOS 3.14.0dev).
With preserve_topology = TRUE
(the default):
Simplifies a geometry, ensuring that the result is a valid geometry having
the same dimension and number of components as the input. The simplification
uses a maximum distance difference algorithm similar to the one used in the
Douglas-Peucker algorithm. In particular, if the input is an areal geometry
(Polygon or MultiPolygon), the result has the same number of shells and
holes (rings) as the input, in the same order. The result rings touch at no
more than the number of touching point in the input (although they may touch
at fewer points).
With preserve_topology = FALSE
:
Simplifies a geometry using the standard Douglas-Peucker algorithm. Ensures
that any polygonal geometries returned are valid. Simple lines are not
guaranteed to remain simple after simplification. Note that in general D-P
does not preserve topology - e.g. polygons can be split, collapse to lines
or disappear, holes can be created or disappear, and lines can cross. To
simplify geometry while preserving topology use TopologyPreservingSimplifier.
(However, using D-P is significantly faster).