From a vector of geometries identify different types of boundaries.
Usage
bounding_boxes(x)
bounding_rect(x)
minimum_rotated_rect(x)
convex_hull(x)
concave_hull(x, concavity)
extreme_coords(x)
bounding_box(x)
Arguments
- x
an object of class
rsgeo
- concavity
a value between 0 and 1 specifying the concavity of the convex hull
Value
bounding_box()
returns a named vector of xmin, ymin, xmax, and ymaxbounding_boxes()
returns a list of bounding box numeric vectors for each geometrybounding_rect()
returns anrs_POLYGON
of the bounding rectangle of each geometryconvex_hull()
returns anrs_POLYGON
of the convex hull for each geometryconcave_hull()
returns anrs_POLYGON
of the specified concavity for each geometryextreme_coords()
returns the extreme coordinates of each geometry as a list where each element is a named vector of xmin, ymin, xmax, and ymax where each element is aPoint
geometry of the extreme valueminimum_rotated_rect()
returns the minimum rotated rectangle covering a geometry as anrs_POLYGON
Details
Note that if you want a convex or concave hull over an entire vector of geometries
you must first union or combine them using either combine_geoms()
or union_geoms()
Examples
lns <- geom_linestring(
1:20,
runif(20, -5, 5),
rep.int(1:5, 4)
)
bounding_box(lns)
#> xmin ymin xmax ymax
#> 1.000000 -4.435066 20.000000 4.073953
bounding_boxes(lns)
#> [[1]]
#> xmin ymin xmax ymax
#> 1.000000 -2.509600 16.000000 1.351401
#>
#> [[2]]
#> xmin ymin xmax ymax
#> 2.000000 -3.248156 17.000000 1.194972
#>
#> [[3]]
#> xmin ymin xmax ymax
#> 3.000000 -4.435066 18.000000 2.367154
#>
#> [[4]]
#> xmin ymin xmax ymax
#> 4.000000 -3.958552 19.000000 2.627060
#>
#> [[5]]
#> xmin ymin xmax ymax
#> 5.000000 -3.009242 20.000000 4.073953
#>
minimum_rotated_rect(lns)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 16.000000000000004, y: -0.16407...
#> [2] Polygon { exterior: LineString([Coord { x: 17.000000000000004, y: 1.194972...
#> [3] Polygon { exterior: LineString([Coord { x: 18.000000000000004, y: 1.616737...
#> [4] Polygon { exterior: LineString([Coord { x: 3.9999999999999982, y: -3.95855...
#> [5] Polygon { exterior: LineString([Coord { x: 20.071459638340365, y: 3.556851...
convex_hull(lns)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 11.0, y: -2.509599975310266 }, ...
#> [2] Polygon { exterior: LineString([Coord { x: 7.0, y: -2.723288901615888 }, C...
#> [3] Polygon { exterior: LineString([Coord { x: 8.0, y: -4.435065584257245 }, C...
#> [4] Polygon { exterior: LineString([Coord { x: 19.0, y: -1.3721352722495794 },...
#> [5] Polygon { exterior: LineString([Coord { x: 10.0, y: -3.0092415190301836 },...
concave_hull(lns, 0.5)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 11.0, y: -2.509599975310266 }, ...
#> [2] Polygon { exterior: LineString([Coord { x: 7.0, y: -2.723288901615888 }, C...
#> [3] Polygon { exterior: LineString([Coord { x: 8.0, y: -4.435065584257245 }, C...
#> [4] Polygon { exterior: LineString([Coord { x: 19.0, y: -1.3721352722495794 },...
#> [5] Polygon { exterior: LineString([Coord { x: 10.0, y: -3.0092415190301836 },...
extreme_coords(lns)
#> [[1]]
#> <rs_POINT[4]>
#> xmin
#> Point(Coord { x: 1.0, y: 1.3514011376537383 }))
#> ymin
#> Point(Coord { x: 11.0, y: -2.509599975310266 }))
#> xmax
#> Point(Coord { x: 16.0, y: -0.1640706416219473 }))
#> ymax
#> Point(Coord { x: 1.0, y: 1.3514011376537383 }))
#>
#> [[2]]
#> <rs_POINT[4]>
#> xmin
#> Point(Coord { x: 2.0, y: -1.9498682138510048 }))
#> ymin
#> Point(Coord { x: 12.0, y: -3.248156241606921 }))
#> xmax
#> Point(Coord { x: 17.0, y: 1.1949720559641719 }))
#> ymax
#> Point(Coord { x: 17.0, y: 1.1949720559641719 }))
#>
#> [[3]]
#> <rs_POINT[4]>
#> xmin
#> Point(Coord { x: 3.0, y: 2.36715373583138 }))
#> ymin
#> Point(Coord { x: 8.0, y: -4.435065584257245 }))
#> xmax
#> Point(Coord { x: 18.0, y: 1.6167376027442515 }))
#> ymax
#> Point(Coord { x: 3.0, y: 2.36715373583138 }))
#>
#> [[4]]
#> <rs_POINT[4]>
#> xmin
#> Point(Coord { x: 4.0, y: -3.958551676478237 }))
#> ymin
#> Point(Coord { x: 4.0, y: -3.958551676478237 }))
#> xmax
#> Point(Coord { x: 19.0, y: -1.3721352722495794 }))
#> ymax
#> Point(Coord { x: 9.0, y: 2.627060494851321 }))
#>
#> [[5]]
#> <rs_POINT[4]>
#> xmin
#> Point(Coord { x: 5.0, y: 4.073952937033027 }))
#> ymin
#> Point(Coord { x: 10.0, y: -3.0092415190301836 }))
#> xmax
#> Point(Coord { x: 20.0, y: 1.4740854036062956 }))
#> ymax
#> Point(Coord { x: 5.0, y: 4.073952937033027 }))
#>