btb_add_centroids {btb} | R Documentation |
Link points to their centroids
Description
Link some points to their centroids in a grid segmentation
Relie des points aux centroides des carreaux auxquels ces points appartiennent (dans un découpage de l'espace en grille carroyée)
Usage
btb_add_centroids(
pts,
iCellSize,
offset = c(0L, 0L),
names_coords = c("x", "y"),
names_centro = c("x_centro", "y_centro"),
add = TRUE
)
Arguments
pts |
: points ( |
iCellSize |
:
|
offset |
(numeric vector of size 2)
|
names_coords |
:
|
names_centro |
|
add |
(boolean)
|
Details
Works with sf points but only with coordinates in meters (and not degrees !). Do not use sf points with GPS coordinates for example.
Value
-
pts
table with additional centroids coordinatesx_centro
andy_centro
(df
ofsf
object) Table
pts
avec les coordonnées des centroïdesx_centro
andy_centro
(objetdf
ofsf
)
Examples
pts <- data.frame(
x = c(656913.1 , 348296.3 , 842276.3 , 716750.0 , 667418.2),
y = c(6855995 , 6788073 , 6385680 , 7003984 , 6585793),
val = 1:5)
btb_add_centroids(pts, 100, names_centro = c("centroX", "centroY"))
btb_add_centroids(pts, 100, offset = c(50, 50), names_centro = c("centroX", "centroY"))
pts2 <- sf::st_as_sf(pts, coords = c("x","y"), crs = 2154)
btb_add_centroids(pts2, 50)