Skip to contents

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 ymax

  • bounding_boxes() returns a list of bounding box numeric vectors for each geometry

  • bounding_rect() returns an rs_POLYGON of the bounding rectangle of each geometry

  • convex_hull() returns an rs_POLYGON of the convex hull for each geometry

  • concave_hull() returns an rs_POLYGON of the specified concavity for each geometry

  • extreme_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 a Point geometry of the extreme value

  • minimum_rotated_rect() returns the minimum rotated rectangle covering a geometry as an rs_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.144445 20.000000  4.747889 
bounding_boxes(lns)
#> [[1]]
#>      xmin      ymin      xmax      ymax 
#>  5.000000 -3.419542 20.000000  4.747889 
#> 
#> [[2]]
#>      xmin      ymin      xmax      ymax 
#>  3.000000 -4.144445 18.000000  4.180226 
#> 
#> [[3]]
#>       xmin       ymin       xmax       ymax 
#>  2.0000000 -0.8920076 17.0000000  4.1903656 
#> 
#> [[4]]
#>       xmin       ymin       xmax       ymax 
#>  1.0000000 -0.9795162 16.0000000  4.4174207 
#> 
#> [[5]]
#>      xmin      ymin      xmax      ymax 
#>  4.000000 -2.921366 19.000000  1.610642 
#> 
minimum_rotated_rect(lns)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 4.427032599912608, y: -2.026464...
#> [2] Polygon { exterior: LineString([Coord { x: 8.000000000000002, y: 4.1802260...
#> [3] Polygon { exterior: LineString([Coord { x: 1.9999999999999993, y: 1.792893...
#> [4] Polygon { exterior: LineString([Coord { x: 16.000000000000004, y: 4.417420...
#> [5] Polygon { exterior: LineString([Coord { x: 4.0, y: -2.921365625225008 }, C...
convex_hull(lns)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 10.0, y: -2.524993175175041 }, ...
#> [2] Polygon { exterior: LineString([Coord { x: 18.0, y: -2.939579407684505 }, ...
#> [3] Polygon { exterior: LineString([Coord { x: 17.0, y: -0.8920075697824359 },...
#> [4] Polygon { exterior: LineString([Coord { x: 6.0, y: -0.97951615229249 }, Co...
#> [5] Polygon { exterior: LineString([Coord { x: 14.0, y: -1.5909375040791929 },...
concave_hull(lns, 0.5)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 10.0, y: -2.524993175175041 }, ...
#> [2] Polygon { exterior: LineString([Coord { x: 18.0, y: -2.939579407684505 }, ...
#> [3] Polygon { exterior: LineString([Coord { x: 17.0, y: -0.8920075697824359 },...
#> [4] Polygon { exterior: LineString([Coord { x: 6.0, y: -0.97951615229249 }, Co...
#> [5] Polygon { exterior: LineString([Coord { x: 14.0, y: -1.5909375040791929 },...
extreme_coords(lns)
#> [[1]]
#> <rs_POINT[4]>
#>                                              xmin 
#>   Point(Coord { x: 5.0, y: 4.3786372523754835 })) 
#>                                              ymin 
#> Point(Coord { x: 20.0, y: -3.4195416909642518 })) 
#>                                              xmax 
#> Point(Coord { x: 20.0, y: -3.4195416909642518 })) 
#>                                              ymax 
#>   Point(Coord { x: 15.0, y: 4.747889121063054 })) 
#> 
#> [[2]]
#> <rs_POINT[4]>
#>                                             xmin 
#>  Point(Coord { x: 3.0, y: -4.144444735720754 })) 
#>                                             ymin 
#>  Point(Coord { x: 3.0, y: -4.144444735720754 })) 
#>                                             xmax 
#> Point(Coord { x: 18.0, y: -2.939579407684505 })) 
#>                                             ymax 
#>   Point(Coord { x: 8.0, y: 4.180226030293852 })) 
#> 
#> [[3]]
#> <rs_POINT[4]>
#>                                              xmin 
#>   Point(Coord { x: 2.0, y: 1.7928934353403747 })) 
#>                                              ymin 
#> Point(Coord { x: 17.0, y: -0.8920075697824359 })) 
#>                                              xmax 
#> Point(Coord { x: 17.0, y: -0.8920075697824359 })) 
#>                                              ymax 
#>   Point(Coord { x: 12.0, y: 4.190365644171834 })) 
#> 
#> [[4]]
#> <rs_POINT[4]>
#>                                            xmin 
#> Point(Coord { x: 1.0, y: 2.9216841561719775 })) 
#>                                            ymin 
#>  Point(Coord { x: 6.0, y: -0.97951615229249 })) 
#>                                            xmax 
#> Point(Coord { x: 16.0, y: 4.417420718818903 })) 
#>                                            ymax 
#> Point(Coord { x: 16.0, y: 4.417420718818903 })) 
#> 
#> [[5]]
#> <rs_POINT[4]>
#>                                             xmin 
#> Point(Coord { x: 4.0, y: -2.9213656252250075 })) 
#>                                             ymin 
#> Point(Coord { x: 4.0, y: -2.9213656252250075 })) 
#>                                             xmax 
#>  Point(Coord { x: 19.0, y: 1.314457633998245 })) 
#>                                             ymax 
#>  Point(Coord { x: 9.0, y: 1.6106420522555709 })) 
#>