Find the population-weighted centre of a municipality

ll_find_pop_centre(
  sf_location,
  sf_population_grid,
  power = 2,
  join = sf::st_intersects
)

Arguments

sf_location
sf_population_grid
power

Defaults to 2. To give more weight to cells with higher population density, raise the number of residents by the power of.

join

Defaults to sf::st_intersects.

Value

Examples

ll_set_folder("~/R/")
#> [1] "~/R/"
name = "Pinzolo" sf_location <- ll_get_nuts_it(name = name, level = "lau", resolution = "high")
#> Source: https://www.istat.it/it/archivio/222527
#> Istat (CC-BY)
lau_grid_name_temp <- stringr::str_c(name, "_lau_high-st_intersects") sf_location_grid <- ll_get_population_grid(match_sf = sf_location, match_name = lau_grid_name_temp, match_country = "IT", join = sf::st_intersects)
#> Data source population grid information: Eurostat, EFGS
#> Source: https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
#> #> ── Column specification ──────────────────────────────────────────────────────── #> cols( #> TOT_P = col_double(), #> GRD_ID = col_character(), #> CNTR_CODE = col_character(), #> METHD_CL = col_character(), #> YEAR = col_double(), #> DATA_SRC = col_character(), #> TOT_P_CON_DT = col_character() #> )
pop_centre <- ll_find_pop_centre(sf_location = sf_location, sf_population_grid = sf_location_grid, power = 2)
#> Warning: st_centroid assumes attributes are constant over geometries of x