Skip to contents

From a vector of geometries idenitfy 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.750805 20.000000  4.795120 
bounding_boxes(lns)
#> [[1]]
#>      xmin      ymin      xmax      ymax 
#>  1.000000 -4.750805 16.000000  4.029242 
#> 
#> [[2]]
#>      xmin      ymin      xmax      ymax 
#>  3.000000 -3.142936 18.000000  3.143420 
#> 
#> [[3]]
#>      xmin      ymin      xmax      ymax 
#>  2.000000 -4.033262 17.000000  4.795120 
#> 
#> [[4]]
#>      xmin      ymin      xmax      ymax 
#>  4.000000 -2.829836 19.000000  2.250505 
#> 
#> [[5]]
#>      xmin      ymin      xmax      ymax 
#>  5.000000 -2.324442 20.000000  3.677400 
#> 
minimum_rotated_rect(lns)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 15.999999999999998, y: -3.96371...
#> [2] Polygon { exterior: LineString([Coord { x: 18.0, y: 3.1434203195385666 }, ...
#> [3] Polygon { exterior: LineString([Coord { x: 2.000000000000001, y: -4.033262...
#> [4] Polygon { exterior: LineString([Coord { x: 18.999999999999996, y: 2.250505...
#> [5] Polygon { exterior: LineString([Coord { x: 19.999999999999996, y: -2.32444...
convex_hull(lns)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 6.0, y: -4.750804777722806 }, C...
#> [2] Polygon { exterior: LineString([Coord { x: 8.0, y: -3.142935521900654 }, C...
#> [3] Polygon { exterior: LineString([Coord { x: 17.0, y: 2.8384346677921712 }, ...
#> [4] Polygon { exterior: LineString([Coord { x: 14.0, y: -2.8298359969630837 },...
#> [5] Polygon { exterior: LineString([Coord { x: 10.0, y: 0.7859983830712736 }, ...
concave_hull(lns, 0.5)
#> <rs_POLYGON[5]>
#> [1] Polygon { exterior: LineString([Coord { x: 6.0, y: -4.750804777722806 }, C...
#> [2] Polygon { exterior: LineString([Coord { x: 8.0, y: -3.142935521900654 }, C...
#> [3] Polygon { exterior: LineString([Coord { x: 17.0, y: 2.8384346677921712 }, ...
#> [4] Polygon { exterior: LineString([Coord { x: 14.0, y: -2.8298359969630837 },...
#> [5] Polygon { exterior: LineString([Coord { x: 10.0, y: 0.7859983830712736 }, ...
extreme_coords(lns)
#> [[1]]
#> <rs_POINT[4]>
#>                                              xmin 
#>    Point(Coord { x: 1.0, y: 4.029242098331451 })) 
#>                                              ymin 
#>   Point(Coord { x: 6.0, y: -4.750804777722806 })) 
#>                                              xmax 
#> Point(Coord { x: 16.0, y: -3.9637103397399187 })) 
#>                                              ymax 
#>    Point(Coord { x: 1.0, y: 4.029242098331451 })) 
#> 
#> [[2]]
#> <rs_POINT[4]>
#>                                             xmin 
#>  Point(Coord { x: 3.0, y: 1.2414750223979354 })) 
#>                                             ymin 
#>  Point(Coord { x: 8.0, y: -3.142935521900654 })) 
#>                                             xmax 
#> Point(Coord { x: 18.0, y: 3.1434203195385635 })) 
#>                                             ymax 
#> Point(Coord { x: 18.0, y: 3.1434203195385635 })) 
#> 
#> [[3]]
#> <rs_POINT[4]>
#>                                             xmin 
#>  Point(Coord { x: 2.0, y: -4.033262005541474 })) 
#>                                             ymin 
#>  Point(Coord { x: 2.0, y: -4.033262005541474 })) 
#>                                             xmax 
#> Point(Coord { x: 17.0, y: 2.8384346677921712 })) 
#>                                             ymax 
#>   Point(Coord { x: 7.0, y: 4.795119611080736 })) 
#> 
#> [[4]]
#> <rs_POINT[4]>
#>                                              xmin 
#>   Point(Coord { x: 4.0, y: -1.725542435888201 })) 
#>                                              ymin 
#> Point(Coord { x: 14.0, y: -2.8298359969630837 })) 
#>                                              xmax 
#>   Point(Coord { x: 19.0, y: 2.250505315605551 })) 
#>                                              ymax 
#>   Point(Coord { x: 19.0, y: 2.250505315605551 })) 
#> 
#> [[5]]
#> <rs_POINT[4]>
#>                                              xmin 
#>   Point(Coord { x: 5.0, y: 3.6773998313583434 })) 
#>                                              ymin 
#> Point(Coord { x: 20.0, y: -2.3244423139840364 })) 
#>                                              xmax 
#> Point(Coord { x: 20.0, y: -2.3244423139840364 })) 
#>                                              ymax 
#>   Point(Coord { x: 5.0, y: 3.6773998313583434 })) 
#>