View source: R/btb_add_centroids.R
btb_add_centroids | R Documentation |
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)
btb_add_centroids( pts, iCellSize, offset = c(0L, 0L), names_coords = c("x", "y"), names_centro = c("x_centro", "y_centro"), add = TRUE )
pts |
: points ( |
iCellSize |
:
|
offset |
(numeric vector of size 2)
|
names_coords |
:
|
names_centro |
|
add |
(boolean)
|
Works with sf points but only with coordinates in meters (and not degrees !). Do not use sf points with GPS coordinates for example.
pts
table with additional centroids coordinates x_centro
and y_centro
(df
of sf
object)
Table pts
avec les coordonnées des centroïdes x_centro
and y_centro
(objet df
of sf
)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.