
create vote offices contours
create_contours.Rd
Crée les contours des bureaux de votes pour une ville donnée
Create all outputs needed for a targeted city
Usage
create_contours(
prep_adr,
cog,
min_points_com,
min_address_bv,
min_address_shoot,
var_cog1 = "code_commune_ref",
var_cog2 = "code_insee",
var_bv1 = "id_brut_bv_reu",
var_geo_score = "geo_score",
var_nbaddress = "nb_adresses",
path_log = NULL
)
Arguments
- prep_adr
Result from prepare_address function :
address : table of geolocalized addresses (all cities of the scope)
com : city contours (sf, all scope)
lcog_ok : scope of cities available
- cog
official targetted city code
- min_points_com
minimal number of address by city (global parameter)
- min_address_bv
minimal number of address by vote office (global parameter)
- min_address_shoot
minimal number of address by polygons in result contours (global parameter)
- var_cog1
name for city code variable in address table
- var_cog2
name for city code variable in city-contours table
- var_bv1
name for bv code variable in address table
- var_geo_score
name for geo_score variable in address table
- var_nbaddress
name for number of addresses for each point in address table
- path_log
path where to write logs (default NULL)
Value
if city in the scope : list of raw contours and simplified contours
NULL otherwise (for looping purpose)
Details
Addresses out of their geographic contours are filtered
Only works for cities verifying at least "min_points_com" points
Create BV contours only if the BV contains at least "min_address_bv" addresses
Creates voronoi polygons (intersected with city borders)
Links each Voronoi polygon with one single BV (hypothesis in "decouplage_ptsBv" function documentation)
Creates BV contours grouping voronoi polygons by BVs
Gives a simplified version of those contours trying to remove little cast polygons with less than "min_address_shoot" addresses (see "shoot_isolated" documentation)
Examples
address <- mapvotr::addresses_sample
contours_com <- mapvotr::contours_com_sample
prep_adr <- prepare_address(
address = address,
contours_com = contours_com,
var_cog1 = "code_commune_ref",
var_bv1 = "id_brut_bv_reu",
path_log = NULL
)
#> [1] "========================================================================="
#> [1] "prepare_address"
#> [1] "========================================================================="
#> [1] "Row number in initial data base"
#> [1] 12335
#> [1] "Launch rm_arrond"
#> [1] "Row number after filtering geo_type"
#> [1] 11928
#> [1] "Launch fget_multiBV"
#> [1] "Row number after filtering cities with at leat 2 BdV"
#> [1] 11875
#> [1] "Convert to sf using BAN coordinates"
#> [1] "Initial number of rows in city contours"
#> [1] 3
#> [1] "Filtering only cities in the scope"
cog <- "29039"
path_log <- NULL
min_points_com <- 50
min_address_bv <- 15
min_address_shoot <- 5
var_cog1 <- "code_commune_ref"
var_cog2 <- "code_insee"
var_bv1 <- "id_brut_bv_reu"
var_geo_score <- "geo_score"
var_nbaddress <- "nb_adresses"
create_contours(prep_adr, cog, min_points_com, min_address_bv, min_address_shoot)
#> [1] "Launch : epsg_from_cog"
#> [1] "First checks"
#> [1] "Launch f_inContour"
#> [1] "0 points removed"
#> [1] "Check if the city can be in the scope"
#> [1] "Launch valid_for_contours"
#> [1] "No problem"
#> [1] "Launch voronoi_com"
#> [1] "19 points with addresses related to different vote offices"
#> [1] "Launch : decouplage_ptsBv"
#> [1] "Join voronoi and passage_ptsBv"
#> [1] "Launch : shoot_isolated"
#> [1] "Launch st_cast_bis"
#> [1] "Launch st_cast_bis"
#> [1] "Launch : count_voro"
#> $contours
#> Simple feature collection with 17 features and 1 field
#> Geometry type: GEOMETRY
#> Dimension: XY
#> Bounding box: xmin: 181289.4 ymin: 6772363 xmax: 188708.9 ymax: 6783302
#> Projected CRS: RGF93 v1 / Lambert-93
#> # A tibble: 17 × 2
#> id_brut_bv_reu geometry
#> <chr> <GEOMETRY [m]>
#> 1 29039_1 MULTIPOLYGON (((183192.3 6774781, 183187.3 6774781, 183189 67…
#> 2 29039_10 MULTIPOLYGON (((184588.2 6776035, 184453.8 6775997, 184258.9 …
#> 3 29039_11 MULTIPOLYGON (((184025.1 6774337, 184016.7 6774336, 184012.8 …
#> 4 29039_12 MULTIPOLYGON (((184547.4 6774384, 184545.7 6774388, 184537.2 …
#> 5 29039_13 MULTIPOLYGON (((183824.6 6772826, 183823.2 6772832, 183825 67…
#> 6 29039_14 POLYGON ((185139.5 6774771, 185132.3 6774776, 185115 6774789,…
#> 7 29039_15 MULTIPOLYGON (((185339.1 6774077, 185322.1 6774095, 185313.2 …
#> 8 29039_16 MULTIPOLYGON (((183100.3 6776071, 183099.7 6776071, 183073.4 …
#> 9 29039_17 MULTIPOLYGON (((184355.2 6772442, 184354.8 6772450, 184356.5 …
#> 10 29039_2 POLYGON ((183028.1 6775009, 183021.5 6775017, 182995.1 677500…
#> 11 29039_3 MULTIPOLYGON (((182654.4 6775014, 182648.7 6775016, 182605.5 …
#> 12 29039_4 MULTIPOLYGON (((182211.7 6776366, 182200.1 6776366, 182193.1 …
#> 13 29039_5 MULTIPOLYGON (((182397.3 6776408, 182374.8 6776430, 182383.5 …
#> 14 29039_6 MULTIPOLYGON (((183414.9 6775840, 183410.2 6775831, 183394 67…
#> 15 29039_7 POLYGON ((183444 6775360, 183445.6 6775363, 183446.8 6775370,…
#> 16 29039_8 POLYGON ((183219.7 6777248, 183212 6777307, 183203.2 6777328,…
#> 17 29039_9 POLYGON ((183689.3 6778818, 183666.5 6778861, 183634.7 677891…
#>
#> $contours_simplified
#> Simple feature collection with 17 features and 1 field
#> Geometry type: GEOMETRY
#> Dimension: XY
#> Bounding box: xmin: 181289.4 ymin: 6772363 xmax: 188708.9 ymax: 6783302
#> Projected CRS: RGF93 v1 / Lambert-93
#> # A tibble: 17 × 2
#> id_brut_bv_reu geometry
#> <chr> <GEOMETRY [m]>
#> 1 29039_1 MULTIPOLYGON (((183189 6774789, 183200 6774814, 183190.2 6774…
#> 2 29039_10 POLYGON ((184588.2 6776035, 184453.8 6775997, 184258.9 677602…
#> 3 29039_11 MULTIPOLYGON (((183880.6 6774730, 183882.7 6774730, 183883.3 …
#> 4 29039_12 MULTIPOLYGON (((184545.7 6774388, 184537.2 6774395, 184537.3 …
#> 5 29039_13 MULTIPOLYGON (((183803.9 6772849, 183799.5 6772843, 183795.1 …
#> 6 29039_14 POLYGON ((186329.7 6774364, 186321.6 6774383, 186245.8 677441…
#> 7 29039_15 MULTIPOLYGON (((185313.2 6774112, 185273.8 6774166, 185276.4 …
#> 8 29039_16 POLYGON ((183100.3 6776071, 183099.7 6776071, 183073.4 677608…
#> 9 29039_17 POLYGON ((184055.6 6773232, 184064.9 6773232, 184069.6 677323…
#> 10 29039_2 POLYGON ((183028.1 6775009, 183021.5 6775017, 182995.1 677500…
#> 11 29039_3 MULTIPOLYGON (((182899.5 6774674, 182895.5 6774670, 182889.2 …
#> 12 29039_4 POLYGON ((182211.7 6776366, 182200.1 6776366, 182193.1 677636…
#> 13 29039_5 MULTIPOLYGON (((183268.1 6776772, 183266.8 6776789, 183268.8 …
#> 14 29039_6 POLYGON ((183484.1 6776001, 183449.8 6775967, 183399.5 677600…
#> 15 29039_7 POLYGON ((184135.1 6775298, 184046.1 6775400, 184042.4 677540…
#> 16 29039_8 POLYGON ((184134.5 6776898, 183751.1 6776883, 183736.3 677689…
#> 17 29039_9 POLYGON ((183689.3 6778818, 183666.5 6778861, 183634.7 677891…
#>