Pourcentage de résidences principales par département
# Nous réutilisons la table logement_par_dep
setwd(Gourbi-Juston-Coumat_tables)
logement_par_dep <- read.csv2("logement_par_dep.csv",sep=";",header=TRUE)
logement_par_dep <- logement_par_dep[,-1]
# Création de la carte
departement <- readOGR(dsn="F:/M2 MIMSE/Semestre 2/Projet informatique/DEPARTEMENT", layer="DEPARTEMENT")
# Jointure entre logement_par_dep et departement pour récupérer les coordonnées géographiques
names(logement_par_dep)[1] <- c("CODE_DEPT")
departement <- merge(departement,logement_par_dep[,c(1,7)], by.x='CODE_DEPT',by.y='CODE_DEPT')
# Lecture des limites des départements
frontiere_departement <- readOGR(dsn="F:/M2 MIMSE/Semestre 2/Projet informatique/DEPARTEMENT", layer="LIMITE_DEPARTEMENT")
frontiere <- frontiere_departement[frontiere_departement$NATURE %in% 'Limite de département',]
europe <- readOGR(dsn="F:/M2 MIMSE/Semestre 2/Projet informatique/ne_110m_admin_0_countries", layer="ne_110m_admin_0_countries")
europe <- europe[europe$region_un=="Europe",]
# coloration
col <- findColours(classIntervals(
departement@data[,12], 100, style="quantile"),
smoothColors("white",98,"purple"))
# Légende
leg <- findColours(classIntervals(
round(departement@data[,12]),6,style="quantile"),
smoothColors("white",3,"purple"),
under="moins de", over="plus de", between="–",
cutlabels=FALSE)
# Projection en Lambert 93
europe <- spTransform(europe, CRS("+init=epsg:2154"))
# Traçage de la carte
plot(frontiere, col="#FFFFFF")
plot(europe, col="#E6E6E6", border="#AAAAAA",lwd=1, add=TRUE)
plot(frontiere, col="#D8D6D4", lwd=6, add=TRUE)
plot(departement,col=col, border=col,lwd=.1, add=TRUE)
title(main="Pourcentage de résidences principales par département")
legend("topright",fill=attr(leg,"palette"),legend=names(attr(leg,"table")),
title="Résidences principale",cex=0.7)