data-raw/carte_Installations.R

### Site : https://www.msss.gouv.qc.ca/professionnels/informations-geographiques-et-de-population/information-geographique/
### Section : Fichiers cartographiques, Fichier cartographique des installations - M02

library(sf)
library(dplyr)
library(usethis)

dir <- paste0(getwd(),"/inst/extdata/FichiersCartographiques/")
initial_files <- list.files(dir)
unzip(  # extraire le fichier .shp
  paste0(dir,"cartes-installations_20191114.zip"),
  exdir = "inst/extdata/FichiersCartographiques",  # répertoire d'extraction
)
after_files <- list.files(dir)
carte_Installations <- st_read(paste0(dir,"Installations.shp"), stringsAsFactors = FALSE)
carte_Installations <- carte_Installations %>%  # convertir les colonnes
  mutate(INSTAL_COD = as.integer(INSTAL_COD),
         ETAB_CODE = as.integer(ETAB_CODE),
         RSS_CODE = as.integer(RSS_CODE),
         MUN_CODE = as.integer(MUN_CODE),
         CLSC_CODE = as.integer(CLSC_CODE),
         MRC_CODE = as.integer(MRC_CODE),
         RLS_CODE = as.integer(RLS_CODE),
         RUIS_CODE = as.integer(RUIS_CODE),
         STATUT_COD = as.integer(STATUT_COD),
         MD_CONS_CO = as.integer(MD_CONS_CO),
         MD_FINAN_C = as.integer(MD_FINAN_C),
         DESIGN_MIN = as.integer(DESIGN_MIN),
         INSTANCE = if_else(INSTANCE=="N", 0L, 1L),
         CHPSY = if_else(CHPSY=="Non", 0L, 1L),
         CHSGS = if_else(CHSGS=="Non", 0L, 1L),
         CHSLD = if_else(CHSLD=="Non", 0L, 1L),
         CLSC = if_else(CLSC=="Non", 0L, 1L),
         CPEJ = if_else(CPEJ=="Non", 0L, 1L),
         CRDITED = if_else(CRDITED=="Non", 0L, 1L),
         CRDPA = if_else(CRDPA=="Non", 0L, 1L),
         CRDPM = if_else(CRDPM=="Non", 0L, 1L),
         CRDPV = if_else(CRDPV=="Non", 0L, 1L),
         CRDPL = if_else(CRDPL=="Non", 0L, 1L),
         CRJDA = if_else(CRJDA=="Non", 0L, 1L),
         CRMDA = if_else(CRMDA=="Non", 0L, 1L),
         CRD = if_else(CRD=="Non", 0L, 1L))
use_data(carte_Installations, overwrite = T)
unlink(paste0(dir,after_files[!after_files %in% initial_files]), TRUE)  # supprimer les fichiers extrait
guiboucher/INESSS-inesss.datasets documentation built on July 27, 2020, 11:54 p.m.