g_unary_op | R Documentation |
These functions implement algorithms that operate on one input geometry for which a new output geometry is generated. The input geometries may be given as a single raw vector of WKB, a list of WKB raw vectors, or a character vector containing one or more WKT strings.
g_buffer(
geom,
dist,
quad_segs = 30L,
as_wkb = TRUE,
as_iso = FALSE,
byte_order = "LSB",
quiet = FALSE
)
g_boundary(
geom,
as_wkb = TRUE,
as_iso = FALSE,
byte_order = "LSB",
quiet = FALSE
)
g_convex_hull(
geom,
as_wkb = TRUE,
as_iso = FALSE,
byte_order = "LSB",
quiet = FALSE
)
g_delaunay_triangulation(
geom,
tolerance = 0,
only_edges = FALSE,
as_wkb = TRUE,
as_iso = FALSE,
byte_order = "LSB",
quiet = FALSE
)
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. |
dist |
Numeric buffer distance in units of the input |
quad_segs |
Integer number of segments used to define a 90 degree curve (quadrant of a circle). Large values result in large numbers of vertices in the resulting buffer geometry while small numbers reduce the accuracy of the result. |
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, |
tolerance |
Numeric value. For |
only_edges |
Logical value. If |
preserve_topology |
Logical value, |
These functions use the GEOS library via GDAL headers.
g_boundary()
computes the boundary of a geometry. Wrapper of
OGR_G_Boundary()
in the GDAL Geometry API.
g_buffer()
builds a new geometry containing the buffer region around
the geometry on which it is invoked. The buffer is a polygon containing
the region within the buffer distance of the original geometry.
Wrapper of OGR_G_Buffer()
in the GDAL API.
g_convex_hull()
computes a convex hull, the smallest convex geometry that
contains all the points in the input geometry. Wrapper of
OGR_G_ConvexHull()
in the GDAL API.
g_delaunay_triangulation()
returns a Delaunay triangulation of the
vertices of the input geometry. Wrapper of OGR_G_DelaunayTriangulation()
in the GDAL API. Requires GEOS >= 3.4.
g_simplify()
computes a simplified geometry. By default, it simplifies
the input geometries while preserving topology (see Note). Wrapper of
OGR_G_Simplify()
/ OGR_G_SimplifyPreserveTopology()
in the GDAL API.
A geometry as WKB raw vector or WKT string, or a list/character vector of
geometries as WKB/WKT with length equal to the number of input geometries.
NULL
(as_wkb = TRUE
) / NA
(as_wkb = FALSE
) 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.
Definitions of these operations are given in the GEOS documentation (https://libgeos.org/doxygen/, GEOS 3.14.0dev), some of which is copied here.
g_boundary()
computes the "boundary" as defined by the DE9IM
(https://en.wikipedia.org/wiki/DE-9IM):
the boundary of a Polygon is the set of linear rings dividing the exterior from the interior
the boundary of a LineString is the two end points
the boundary of a Point/MultiPoint is defined as empty
g_buffer()
always returns a polygonal result. The negative or
zero-distance buffer of lines and points is always an empty Polygon.
g_convex_hull()
uses the Graham Scan algorithm.
g_simplify()
:
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).
N.B., preserve_topology = TRUE
does not preserve boundaries shared between
polygons.
g1 <- "POLYGON((0 0,1 1,1 0,0 0))"
g_boundary(g1, as_wkb = FALSE)
g2 <- "POINT (0 0)"
g_buffer(g2, dist = 10, as_wkb = FALSE)
g3 <- "GEOMETRYCOLLECTION(POINT(0 1), POINT(0 0), POINT(1 0), POINT(1 1))"
g_convex_hull(g3, as_wkb = FALSE)
g4 <- "MULTIPOINT(0 0,0 1,1 1,1 0)"
g_delaunay_triangulation(g4, as_wkb = FALSE)
g5 <- "LINESTRING(0 0,1 1,10 0)"
g_simplify(g5, tolerance = 5, as_wkb = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.