btb_add_centroids {btb}R Documentation

Link points to their centroids

Description

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 (df of sf object)

iCellSize

:

  • Size of the square cells (meters)

  • Taille des côtés des carreaux (mètres)

offset

(numeric vector of size 2)

  • Offset for a grid non centered on the geographical referential origin

  • Décalage si utilisation d'une grille non centrée sur l'origine du référentiel géographique

names_coords

:

  • Names of the latitude-longitude variables (character vector)

  • Noms des variables de latitude-longitude (vecteur character)

names_centro
  • Names of the latitude-longitude variables for added centroids (character vector)

    • Noms des variables de latitude-longitude pour les centroïdes ajoutés (vecteur character)

add

(boolean)

  • If TRUE : returns pts + centroids coordinates

  • Si TRUE : retourne pts + les coordonnées des centroïdes

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

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)

[Package btb version 0.2.0 Index]