Summarise changing geometries based on a group identifier
Source:R/summarise_geometry.R
summarise_geometry.Rd
Changing geometries are summarised for all time periods as a single geometry
(of types POINT
, POLYGON
, MULTIPOLYGON
) in order to pass them
as a spatial dimension to post_*
objects.
The family of functions summarise_geometry_*()
or summarize_geometry_*()
are helpers to create these summarised geometries.
Usage
summarise_geometry_union(
x,
group_id = NULL,
sf_column_name = NULL,
.checks = TRUE
)
summarize_geometry_union(
x,
group_id = NULL,
sf_column_name = NULL,
.checks = TRUE
)
summarise_geometry_centroid(
x,
group_id = NULL,
sf_column_name = NULL,
.checks = TRUE
)
summarize_geometry_centroid(
x,
group_id = NULL,
sf_column_name = NULL,
.checks = TRUE
)
summarise_geometry_bbox(
x,
group_id = NULL,
sf_column_name = NULL,
.checks = TRUE,
rotated = FALSE
)
summarize_geometry_bbox(
x,
group_id = NULL,
sf_column_name = NULL,
.checks = TRUE,
rotated = FALSE
)
summarise_geometry_convex_hull(
x,
group_id = NULL,
sf_column_name = NULL,
.checks = TRUE
)
summarize_geometry_convex_hull(
x,
group_id = NULL,
sf_column_name = NULL,
.checks = TRUE
)
Arguments
- x
object
POLYGON
/MULTIPOLYGON
changing geometries to summarise based ongroup_id
.- group_id
see
?post_array
for details. Defaults to the first non-spatial, non-temporal column in x.- sf_column_name
(character) name of column with changing geometries. Defaults to active
sf_column
.- .checks
internal, should creation arguments be checked?
- rotated
(logical) if TRUE, the minimum rotated rectangle is returned, if FALSE the minimum unrotated rectangle or bounding box is returned. Defaults to FALSE
Details
A custom function to summarise geometries can be passed onto the
coercion functions as_post_*()
, given that the parameters x
,
group_id
and sf_column_name
are included in the function.
Additional arguments can be passed to the function as necessary.
See vignette("post02_geomsum")
for more information.
Functions
summarise_geometry_union()
: computes the geometry summary as the union and dissolve of the changing geometriessummarise_geometry_centroid()
: computes the geometry summary as the centroid of the union and dissolve of the changing geometriessummarise_geometry_bbox()
: computes the geometry summary as the bounding box or minimum rectangle of the union and dissolve of the changing geometriessummarise_geometry_convex_hull()
: computes the geometry summary as the convex hull of the union and dissolve of the changing geometries
Examples
# union and dissolve
summarise_geometry_union(polygons)
#> Geometry set for 5 features
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -0.2974337 ymin: -0.0029756 xmax: 0.9730806 ymax: 1.153558
#> Geodetic CRS: WGS 84
#> POLYGON ((0.4971355 0.8717961, 0.5474949 0.8088...
#> POLYGON ((-0.1774445 0.5995572, -0.1843257 0.58...
#> POLYGON ((0.28657 0.6085207, 0.2663408 0.622264...
#> POLYGON ((0.5737123 0.4613799, 0.6063966 0.4263...
#> POLYGON ((0.2973931 0.2557416, 0.2813385 0.2544...
# centroid
summarise_geometry_centroid(polygons)
#> Geometry set for 5 features
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -0.002543201 ymin: 0.17772 xmax: 0.752585 ymax: 0.9018588
#> Geodetic CRS: WGS 84
#> POINT (0.647816 0.9018588)
#> POINT (-0.002543201 0.8403816)
#> POINT (0.3897167 0.5412363)
#> POINT (0.752585 0.3538271)
#> POINT (0.4690683 0.17772)
# bounding box or minimum unrotated rectangle
summarise_geometry_bbox(polygons)
#> Geometry set for 5 features
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -0.2974337 ymin: -0.0029756 xmax: 0.9730806 ymax: 1.153558
#> Geodetic CRS: WGS 84
#> POLYGON ((0.4361026 0.7456421, 0.9005707 0.7456...
#> POLYGON ((-0.2974337 0.5814869, 0.3796448 0.581...
#> POLYGON ((0.2145846 0.4039274, 0.5898739 0.4039...
#> POLYGON ((0.5272362 0.1748722, 0.9730806 0.1748...
#> POLYGON ((0.2452129 -0.0029756, 0.6988282 -0.00...
# minimum rotated rectangle
summarise_geometry_bbox(polygons, rotated = TRUE)
#> Warning: st_minimum_rotated_rectangle does not work correctly for longitude/latitude data
#> Geometry set for 5 features
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -0.4068963 ymin: -0.05907163 xmax: 0.9881167 ymax: 1.232265
#> Geodetic CRS: WGS 84
#> POLYGON ((0.5137787 1.117004, 0.3759687 0.90381...
#> POLYGON ((0.3796448 0.767853, 0.2316513 1.23226...
#> POLYGON ((0.3321186 0.7217665, 0.1760477 0.4920...
#> POLYGON ((0.6633874 0.573032, 0.500051 0.369666...
#> POLYGON ((0.678186 -0.05907163, 0.7911437 0.289...
# convex hull
summarise_geometry_convex_hull(polygons)
#> Geometry set for 5 features
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -0.2974337 ymin: -0.0029756 xmax: 0.9730806 ymax: 1.153558
#> Geodetic CRS: WGS 84
#> POLYGON ((0.7568336 0.7456421, 0.8157179 0.7671...
#> POLYGON ((-0.2341393 0.5814869, -0.1843257 0.58...
#> POLYGON ((0.4606164 0.4039274, 0.5749458 0.4441...
#> POLYGON ((0.8757658 0.1748722, 0.8918794 0.1923...
#> POLYGON ((0.505091 -0.0029756, 0.6988282 0.0046...