Création de fonds de cartes statiques et dynamiques avec R et ...
Création de fonds de cartes statiques et dynamiques avec R et ...
Création de fonds de cartes statiques et dynamiques avec R et ...
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Création <strong>de</strong> <strong>fonds</strong> <strong>de</strong> <strong>cartes</strong> <strong>statiques</strong> <strong>et</strong><strong>dynamiques</strong> <strong>avec</strong> R <strong>et</strong> Google MapsJérôme SUEURMNHNUMR CNRS 7205 - OSEBMardi 7 février 2012
PlanPourquoi faire ?Cartes <strong>statiques</strong>RgoogleMapsdismoCartes <strong>dynamiques</strong>googleVisplotGoogleMapsAutres possibilitésRéférences
PlanPourquoi faire ?Cartes <strong>statiques</strong>RgoogleMapsdismoCartes <strong>dynamiques</strong>googleVisplotGoogleMapsAutres possibilitésRéférences
Pourquoi faire ?◮ <strong>cartes</strong> <strong>de</strong> distribution d’espèces,◮ <strong>cartes</strong> <strong>de</strong> <strong>de</strong>nsité par pays,◮ suivi <strong>de</strong> déplacement (tracking, télédétection),◮ <strong>cartes</strong> <strong>de</strong> territoires, <strong>de</strong> zones végétales, <strong>et</strong>c.
PlanPourquoi faire ?Cartes <strong>statiques</strong>RgoogleMapsdismoCartes <strong>dynamiques</strong>googleVisplotGoogleMapsAutres possibilitésRéférences
Cartes <strong>statiques</strong>RgoogleMaps◮ Auteur : Markus Loecher,◮ Nécessite les packages : png, ReadImages,◮ Interroge Google Maps <strong>et</strong> récupère les <strong>fonds</strong> <strong>de</strong> carte,◮ Ajoute <strong>de</strong>s points <strong>et</strong> lignes sur les <strong>fonds</strong> <strong>de</strong> carte.
Cartes <strong>statiques</strong>RgoogleMapsCoordonnées <strong>et</strong> noms <strong>de</strong>s principaux sites du MNHN en IdF :lat
Cartes <strong>statiques</strong>RgoogleMapsCarte définie à partir d’un point central <strong>et</strong> d’un niveau <strong>de</strong> zoom, sauvéedans un fichier .png :library(RgoogleMaps)paris1
Cartes <strong>statiques</strong>RgoogleMapsPour afficher la carte dans x11, utiliser PlotOnStaticMap() :PlotOnStaticMap(paris1)
Cartes <strong>statiques</strong>RgoogleMapsLa même carte <strong>avec</strong> un autre fond :paris2
Cartes <strong>statiques</strong>RgoogleMapsLa fonction qbbox() [quantiles bounding box] perm<strong>et</strong> <strong>de</strong> cadrer la carteen fonction <strong>de</strong>s points à afficher :bb
Cartes <strong>statiques</strong>RgoogleMapsPlotOnStaticMap(paris3)
Cartes <strong>statiques</strong>RgoogleMapsPour illustrer la carte <strong>avec</strong> <strong>de</strong>s points ou <strong>de</strong>s lignes, utiliser la fonctionPlotOnStaticMap() :PlotOnStaticMap(paris3,lat = as.numeric(lat), lon = as.numeric(long),cex = 2, pch = 19, col = "red", add = FALSE)●●●●●
Cartes <strong>statiques</strong>dismo◮ Auteurs : Robert J. Hijmans, Steven Phillips, John Leathwick andJane Elith◮ Nécessite les packages : raster, XML, RGDAL, <strong>et</strong> sp,◮ Fonctions utiles en cartographies :◮ geoco<strong>de</strong> pour la localisation◮ gmap pour la projection◮ Wrapper <strong>de</strong> RGoogleMaps pour <strong>de</strong>s <strong>de</strong>ux fonctions.
Cartes <strong>statiques</strong>dismoA partir d’un mot-clé :library(dismo)(x
Cartes <strong>statiques</strong>dismoOn affiche dans x11 <strong>avec</strong> plot()plot(g)
Cartes <strong>statiques</strong>dismoA partir d’un ensemble <strong>de</strong> points :xy
Cartes <strong>statiques</strong>dismoLa projection est <strong>de</strong> type Mercator.Pour ajouter <strong>de</strong>s annotations, il faut donc transformées les données <strong>avec</strong>la fonction Mercator() :Mxy
Cartes <strong>statiques</strong>dismoplot(g)points(Mxy, col=2, pch=20)text(Mxy, labels=nom, col=2, pos=4)●Musée <strong>de</strong> l'Homme● Arbor<strong>et</strong>um <strong>de</strong> Chèvreloup●●Jardin <strong>de</strong>s PlantesIPH● Zoo <strong>de</strong> Vincennes●Brunoy
PlanPourquoi faire ?Cartes <strong>statiques</strong>RgoogleMapsdismoCartes <strong>dynamiques</strong>googleVisplotGoogleMapsAutres possibilitésRéférences
Cartes <strong>dynamiques</strong>googleVisPrincipe :1. création d’un data.frame <strong>avec</strong> les données <strong>de</strong> localisation par <strong>de</strong>s :◮ mots-clé◮ données latitu<strong>de</strong> / longitu<strong>de</strong> en décimales2. création du co<strong>de</strong> html / javascript <strong>avec</strong> gvisMap()3. projection <strong>avec</strong> plot()
Cartes <strong>dynamiques</strong>googleVisLes arguments pour les données :◮ data ⇒ data.frame,◮ locationvar ⇒ chaîne <strong>de</strong> caractères, le nom <strong>de</strong> la colonne <strong>de</strong> datacontenant les données <strong>de</strong> localisation,◮ tipvar ⇒ chaîne <strong>de</strong> caractères, le nom <strong>de</strong> la colonne <strong>de</strong> datacontenant le texte <strong>de</strong>s étiqu<strong>et</strong>tes, accepte du co<strong>de</strong> html.
Cartes <strong>dynamiques</strong>googleVisLocalisation par mots-clé :library(googleVis)df
Cartes <strong>dynamiques</strong>googleVisLocalisation par donnée longitu<strong>de</strong> / latitu<strong>de</strong> :latlong
Cartes <strong>dynamiques</strong>googleVisL’argument graphique option est une list <strong>avec</strong> les différentes options :◮ gvis.editor = TRUE ⇒ modification en ligne,◮ enableScrollWheel = TRUE ⇒ zoom,◮ showTip = TRUE ⇒ étiqu<strong>et</strong>tes pour chaque point,◮ showLine = TRUE ⇒ ligne entre les points,◮ lineColor ⇒ couleur <strong>de</strong>s lignes,◮ lineWidth ⇒ épaisseur <strong>de</strong>s lignes,◮ mapType ⇒ type <strong>de</strong> carte (normal, terrain, satellite, hybrid)◮ useMapTypeControl = TRUE ⇒ changement <strong>de</strong> type <strong>de</strong> fond <strong>de</strong>carte en ligne,◮ zoomLevel ⇒ niveau <strong>de</strong> zoom,◮ width, height ⇒ largeur <strong>et</strong> hauteur en pixels.
Cartes <strong>dynamiques</strong>googleVismymap3
Cartes <strong>dynamiques</strong>googleVisExemple <strong>de</strong> distribution d’une cigale méditerranéenne : Dimissalnadimissa :http ://sueur.jerome.perso.neuf.fr/pubmore.html
Cartes <strong>dynamiques</strong>googleVisExemple <strong>de</strong> tracking : données sur le traj<strong>et</strong> d’un individu <strong>de</strong> Bernachenon<strong>et</strong>te (Branta leucopsis)Source : Larry Griffin <strong>et</strong> David Cabot http ://www.movebank.orgLes données :head(goose)location.long location.lat8553 -10.22300 54.115838554 -10.22300 54.115838555 -10.22350 54.115338556 -10.20200 54.119168557 -10.20183 54.119338558 -10.20100 54.13066
Cartes <strong>dynamiques</strong>googleVislatlongnom1 54.11583:-10.223 Barnacle goose2 54.11583:-10.223 Barnacle goose3 54.11533:-10.2235 Barnacle goose4 54.11916:-10.202 Barnacle goose5 54.11933:-10.20183 Barnacle goose6 54.13066:-10.201 Barnacle goose
Cartes <strong>dynamiques</strong>googleVisLa carte :mymap4
Cartes <strong>dynamiques</strong>googleVisIl y a <strong>de</strong>ux autres fonctions pour <strong>de</strong>s <strong>cartes</strong> <strong>de</strong> <strong>de</strong>nsité par pays :◮ gvisIntensityMap(),◮ gvisGeoMap().
Cartes <strong>dynamiques</strong>plotGoogleMaps◮ Auteur : Milan Kilibarda,◮ Deux fonctions :◮ plotGoogleMaps() <strong>cartes</strong> dynamique <strong>avec</strong> projection <strong>de</strong> donnéesspatiales (polygones, points),◮ bubbleGoogleMaps() carte dynamique <strong>avec</strong> projection <strong>de</strong>s pointsmodifiables (bubbles).
Cartes <strong>dynamiques</strong>plotGoogleMapsObject <strong>de</strong> classe Spatial du package sp qui contient :◮ la ’bounding box’,◮ le CRS (coordinate reference system)◮ <strong>de</strong>s sous-classes selon le type <strong>de</strong> données spatiales◮ SpatialPoints, SpatialPointsDataFrame,◮ SpatialLines, SpatialLinesDataFrame,◮ SpatialPolygons, SpatialPolygonsDataFrame,◮ SpatialPixels,◮ SpatialGrid
Cartes <strong>dynamiques</strong>plotGoogleMapsDonnées meuse <strong>et</strong> meuse.grid du package sp.Préparation <strong>de</strong>s données :-(Données <strong>de</strong> différentes mesures <strong>de</strong> pollutionlibrary(plotGoogleMaps)data(meuse)coordinates(meuse)
Cartes <strong>dynamiques</strong>plotGoogleMapsProjection simple <strong>de</strong>s points <strong>avec</strong> étiqu<strong>et</strong>tes complètes, écriture dans unfichier .html :m
Cartes <strong>dynamiques</strong>plotGoogleMapsCréation d’un carte <strong>avec</strong> plusieurs calques (projections). Premier calque<strong>avec</strong> les points <strong>de</strong> mesure <strong>de</strong> pollution :mapMeusePoints
Cartes <strong>dynamiques</strong>plotGoogleMapsProject du taux <strong>de</strong> pollution au zinc par <strong>de</strong>s points <strong>de</strong> tailleproportionnelle :m
PlanPourquoi faire ?Cartes <strong>statiques</strong>RgoogleMapsdismoCartes <strong>dynamiques</strong>googleVisplotGoogleMapsAutres possibilitésRéférences
Autres possibilités◮Écriture <strong>de</strong> fichiers .kml (Google Earth) <strong>avec</strong> la fonctionwriteOGR() du package rgdal,◮ package DeducerSpatial : un GUI pour la projection spatialefonctionant <strong>avec</strong> JGR. Vidéo ici.◮ package ggmap fonctionnant sur le principle <strong>de</strong> ggplot2.
PlanPourquoi faire ?Cartes <strong>statiques</strong>RgoogleMapsdismoCartes <strong>dynamiques</strong>googleVisplotGoogleMapsAutres possibilitésRéférences
Références◮ Bivand <strong>et</strong> al. 2008 – Applied spatial data analysis with R. Use R !Springer.◮ dismo : http ://cran.r-project.org/web/packages/dismo/in<strong>de</strong>x.html◮ plotGoogleMaps : http ://cran.at.rproject.org/web/packages/plotGoogleMaps/in<strong>de</strong>x.html◮ RgoogleMaps :http ://cran.r-project.org/web/packages/RgoogleMaps/in<strong>de</strong>x.html◮ googleVis :http ://cran.r-project.org/web/packages/googleVis/in<strong>de</strong>x.html