Created
March 3, 2016 15:26
-
-
Save rCarto/08f252cde44001fa49e3 to your computer and use it in GitHub Desktop.
Carton cartographique / Map Inset
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
# Démarrer le package cartography | |
library(cartography) | |
# Charger les données stockées sur le web | |
load((url("http://wukan.ums-riate.fr/bond/bondfiles.RData"))) | |
fdim <- getFigDim(spdf = WorldCountries[WorldCountries$ISO3 %in% | |
c( "RUS","NZL", "ARG"),], | |
width = 750, res = 120, | |
mar = c(0,0,1.2,0)) | |
png(filename = "mapcarton.png", | |
width = fdim[1], height = fdim[2], | |
res = 120) | |
# Gestion des marges de la figure | |
par(mar = c(0,0,1.2,0)) | |
# Centrer la carte | |
plot(WorldCountries[WorldCountries$ISO3 %in% c( "RUS","NZL", "ARG"),], | |
border = NA, | |
bg = "#cdd2d4") | |
# Afficher les pays | |
plot(WorldCountries, col = "#f5f5f3ff", border = "#a9b3b4ff", | |
add = T) | |
# Afficher les cercles proportionnels | |
propSymbolsLayer(spdf = WorldCountries, df = BondVisits, | |
var = "n", legend.pos = "left", | |
legend.title.txt = "Nombre de\nvisites", | |
border = "#f5f5f3ff",legend.values.cex = 0.45, | |
col = "#bb2b20ff", inches = 0.2) | |
# Ajouter un habillage | |
layoutLayer(title = "James Bond autour du Monde", | |
author = "Auteur : T. Giraud - 2016", | |
sources = "Source : Wikipedia.org - 2015", | |
scale = NULL, frame = FALSE, | |
col = "white", | |
coltitle = "black") | |
# Ajouter un carton, une carte dans la carte | |
par(fig = c(grconvertX(c(6000000,16000000), from="user", to="ndc"), | |
grconvertY(c(-6600000,1500000), from="user", to="ndc")), | |
mar = c(0,0,0,0), | |
new = TRUE) | |
# Le carton recouvrira l'Australie | |
# Centrer la carte sur l'Europe | |
plot(WorldCountries[WorldCountries$ISO2 %in% c("PT", "LV"),], | |
border = NA, | |
bg = "#cdd2d4") | |
# Ajout des pays | |
plot(WorldCountries, col = "#f5f5f3ff", | |
border = "#a9b3b4ff", | |
add=T) | |
# Afficher les cercles proportionnels | |
propSymbolsLayer(spdf = WorldCountries, df = BondVisits, | |
var = "n", legend.pos = "n", | |
border = "#f5f5f3ff", | |
col = "#bb2b20ff", inches = 0.2) | |
# Ajouter un cadre autour de la figure | |
box(col = "grey20") | |
# Ajouter un titre au carton | |
mtext(text = "Zoom sur l'Europe", side = 3, line = -1, | |
adj = 0.95, cex = 0.8, font = 2) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment