Commit 898879c0 authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

script/admin_express.R

	- création des données epci et commune dans data-common/so-ii

Refs #5
Showing with 33 additions and 0 deletions
+33 -0
# Functions
# Data
input_dir = geau::current_version("data-common/data/IGN/ADMIN-EXPRESS/version")
commune = sf::st_read(file.path(input_dir, "COMMUNE.shp"))
commune = sf::st_drop_geometry(commune)
commune = commune[c("NOM", "NOM_M", "INSEE_COM", "INSEE_DEP", "INSEE_REG", "SIREN_EPCI")]
names(commune) = c("commune_name", "commune_nam_cap", "commune", "departement", "region", "epci")
rownames(commune) = commune[["commune"]]
commune = commune[geau::so_ii_scope, ]
commune_so_ii = read.csv2(geau::current_version("data-common/so-ii/commune"))
commune_so_ii = merge(commune_so_ii[c("commune", "syble", "symbo")], commune)
epci = sf::st_read(file.path(input_dir, "EPCI.shp"))
epci = sf::st_drop_geometry(epci)
names(epci) = c("id", "epci", "epci_name", "epci_nature")
rownames(epci) = epci[["epci"]]
epci = epci[unique(commune[["epci"]]), c("epci", "epci_name", "epci_nature")]
# Save
today = Sys.Date()
write.csv2(
commune_so_ii,
sprintf("data-common/so-ii/commune/commune-%s.csv", today),
row.names = FALSE
)
write.csv2(
epci,
sprintf("data-common/so-ii/epci/epci-%s.csv", today),
row.names = FALSE
)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment