g_simplify | R Documentation |
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).
g_simplify(
geom,
tolerance,
preserve_topology = TRUE,
as_wkb = TRUE,
as_iso = FALSE,
byte_order = "LSB",
quiet = FALSE
)
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 |
preserve_topology |
Logical value, |
as_wkb |
Logical value, |
as_iso |
Logical value, |
byte_order |
Character string specifying the byte order when output is
WKB. One of |
quiet |
Logical value, |
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).
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.
preserve_topology = TRUE
does not preserve boundaries shared between
polygons.
g <- "LINESTRING(0 0,1 1,10 0)"
g_simplify(g, tolerance = 5, as_wkb = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.