Utility functions for accessing coordinates from a geometry.
Value
an object of class rs_POINT
.
Whereas n_coords()
returns an integer vector of the same length as x
.
Details
n_coords
returns the total number of coordinates in a geometrycoord_first()
returns the first coordinate in a geometrycoord_last()
returns the last coordinate in a geometrycoord_n()
returns the nth coordinate in a geometry
Examples
lines <- geom_linestring(1:10, 1:10)
n_coords(lines)
#> [1] 10
coord_first(lines)
#> <rs_LINESTRING[1]>
#> [1] Point(Coord { x: 1.0, y: 1.0 }))
coord_last(lines)
#> <rs_LINESTRING[1]>
#> [1] Point(Coord { x: 10.0, y: 10.0 }))
coord_n(lines, 5)
#> <rs_LINESTRING[1]>
#> [1] Point(Coord { x: 5.0, y: 5.0 }))