Last active
August 29, 2015 14:05
-
-
Save ElCep/3f29ff211dd4f5b6f2b5 to your computer and use it in GitHub Desktop.
Un script pour faire une carte du registre parcellaire graphique avec le code couleurs officiel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rgdal)#pour charger les données spatiales | |
library(plyr)#pour faire la jointure | |
library(OpenStreetMap)#pour avoir un beau font osm | |
setwd("~/Téléchargements/RPG_2011_066/") | |
po.shp<-readOGR(dsn = ".", layer = "RPG_2011_066") | |
po.shp@data$Valeur<-po.shp@data$CULT_MAJ | |
xls.df<-read.table("rpg_2011_ codes_groupes_cultures_et_couleurs.csv",header = T,sep=",") | |
xls.df$couleur.RVB<-as.character(xls.df$couleur.RVB) | |
palette <- xls.df$couleur.RVB | |
po.shp@data<-join(po.shp@data,xls.df,by="Valeur") | |
#reprojetter avec osm | |
po.shp<-spTransform(po.shp,osm()) | |
#charger data OSM | |
map.osm<-openmap(c(42.75023919870402,2.1807861328125),c(42.292751719296284,3.350830078125),type="osm") | |
png("map_osm.png",width = 2000,height = 1800, res = 200) | |
plot(map.osm,axes = T) | |
plot(po.shp,col=po.shp@data$couleur.RVB,add=T) | |
legend("topleft", # position | |
legend = xls.df$Libellé, | |
title = "Registre Parcellaire 2011", | |
fill = palette, | |
cex = 0.56, | |
ncol = 3, | |
bty = "n") # border | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment