Simple features in R (10)

Return point coordinates contained in a sf object:

st_coordinates(nc) |> class()
## [1] "matrix" "array"
st_coordinates(nc) |> head()
##              X        Y L1 L2 L3
## [1,] -81.47276 36.23436  1  1  1
## [2,] -81.54084 36.27251  1  1  1
## [3,] -81.56198 36.27359  1  1  1
## [4,] -81.63306 36.34069  1  1  1
## [5,] -81.74107 36.39178  1  1  1
## [6,] -81.69828 36.47178  1  1  1
st_coordinates(nc) |> tail()
##                 X        Y L1 L2  L3
## [2524,] -77.96587 34.24229  1  1 100
## [2525,] -77.96073 34.18924  1  1 100
## [2526,] -77.95853 33.99258  1  1 100
## [2527,] -78.03481 33.91429  1  1 100
## [2528,] -78.57972 33.88199  1  1 100
## [2529,] -78.65572 33.94867  1  1 100

From ?st_coordinates:

[…] for MULTIPOLYGON L1 refers to the main ring or holes, L2 to the ring id in the MULTIPOLYGON, and L3 to the simple feature.