tag:blogger.com,1999:blog-90554978822074624762024-03-12T17:55:15.749-07:00Data & GIS tipsharmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.comBlogger57125tag:blogger.com,1999:blog-9055497882207462476.post-3886027382072885092017-02-14T13:15:00.001-08:002017-02-15T00:04:11.450-08:00Parcourir le Monde<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjPZsVgU8T2WtmQNtsgmVu8a40-cyKcd0JBgZuDrl2RYbCAiC2dKiHMRXddTmwi965VS2yN3xWU03GcAyS2ukB2E-GsH2ORYpuhKcdFLRGrfZFRpLf9jDJkNM3Vm69nA-O7xMrc-IdD-o/s1600/time+zones.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="98" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjPZsVgU8T2WtmQNtsgmVu8a40-cyKcd0JBgZuDrl2RYbCAiC2dKiHMRXddTmwi965VS2yN3xWU03GcAyS2ukB2E-GsH2ORYpuhKcdFLRGrfZFRpLf9jDJkNM3Vm69nA-O7xMrc-IdD-o/s200/time+zones.png" width="200" /></a>Quel est l'itinéraire idéal pour parcourir le Monde ? Combien de temps de vol cela prendrait ? Quels sont les deux pays les plus distants l'un de l'autre ?<br />
Dans ce post, j'ai fait mumuse avec la carte du globe, et appris des choses au sujet des distances orthodromiques et des voyageurs de commerce. Bon voyage !<br />
<br />
<br />
<a name='more'></a><br />
Dernièrement, j'ai eu un échange avec <a href="https://twitter.com/matamix" target="_blank">@matamix</a> au sujet du calcul de trajets permettant de couvrir un ensemble de points de façon optimale.<br />
<br />
Nous avons échangé au sujet du code, puis une question m'est venue : dans quel ordre devrais-je visiter les différents pays, dans l'éventualité d' un tour du monde (rêvons un peu). C'est la problématique du voyageur de commerce, qui doit démarcher un certain nombre d'adresses en un minimum de temps. Il s'avère que la problématique du voyageur de commerce peut s'appliquer à des domaines non spatiaux, comme ordonner des séquences génétiques, voire regrouper des individus (au sens statistique) selon leur proximité : intéressant !<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://press.princeton.edu/images/k9531.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://press.princeton.edu/images/k9531.gif" height="320" width="210" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">"Attrape-moi si tu peux !"</td></tr>
</tbody></table>
<br />
Tout d'abord, il faut se poser la question des distances entre les différents pays. L'espace dans lequel on doit travailler n'est pas euclidien, plan, mais sphérique. Ainsi, pour rejoindre le Japon depuis les Etats-Unis, inutile de traverser l'Atlantique, bien sûr. Les distances que l'on doit calculer sont les <a href="https://en.wikipedia.org/wiki/Great-circle_distance" target="_blank">distances de grands cercles</a> ou orthodromiques. Il existe apparemment différentes méthodes, la plus courante étant celle utilisant <a href="https://en.wikipedia.org/wiki/Spherical_law_of_cosines" target="_blank">la loi sphérique des Cosinus</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://upload.wikimedia.org/wikipedia/commons/thumb/c/cb/Illustration_of_great-circle_distance.svg/298px-Illustration_of_great-circle_distance.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/cb/Illustration_of_great-circle_distance.svg/298px-Illustration_of_great-circle_distance.svg.png" width="200" /></a></div>
<br />
Sous R, on peut calculer 4 sortes de distances des grands cercles grâce au paquet geosphere.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.naturalearthdata.com/wp-content/themes/NEV/images/nev_logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.naturalearthdata.com/wp-content/themes/NEV/images/nev_logo.png" height="41" width="200" /></a></div>
<br />
J'ai récupéré les contours des pays depuis le magnifique <a href="http://www.naturalearthdata.com/" target="_blank">Natural Earth</a>, déterminé le centre des pays, et calculé les distances entre chaque, de sorte à réaliser une matrice de distance entre les différents pays. Cette matrice peut être vue comme un réseau constitué de noeuds : les pays, connectés entre eux par des arêtes de poids égal à la distance qui les sépare.<br />
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGeoXx2_anOMUZdxzzfBlXKDJiQAXREnXyyLyMC3-uSRMqP853Whf25-mRcjN56svgv3sowYUWLnnJd9iRTBaK7Y5H2QCRtlMESmYX5UjlueoHhm7R9MngQ5vre1FHSOdK9GW70k4Gjsc/s1600/flux.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="228" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGeoXx2_anOMUZdxzzfBlXKDJiQAXREnXyyLyMC3-uSRMqP853Whf25-mRcjN56svgv3sowYUWLnnJd9iRTBaK7Y5H2QCRtlMESmYX5UjlueoHhm7R9MngQ5vre1FHSOdK9GW70k4Gjsc/s400/flux.png" width="400" /></a></div>
<br /></div>
<br />
On obtient une matrice des distances orthodromiques, dont voici ci-dessous une illustration, avec 177 lignes et 177 colonnes (autant de pays que dans la couche des pays), soit 177^2 "cases". Plus la couleur est claire et plus la valeur de distance est grande. On voit que la diagonale est obscure. Les poids sur celle-ci sont nuls, puisque la distance de la France à la France est nulle. On voit que la matrice est symétrique puisque la distance, à vol d'oiseau, est la même de la France à l'Espagne que de l'Espagne à la France.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzBKIZm3o2nKMS2mZGMoCXHGpE5Ji3mgz-DKSNCL32odoQOw31ZhC_XufPxOxtfZcrrvyqM5egFFDXDv2gsk-Zg84GhUm8t91JUG7B9Vq-2Kfx0lKjNmtl68tZIQuL9mGqMhPStadHG3M/s1600/Rplot.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzBKIZm3o2nKMS2mZGMoCXHGpE5Ji3mgz-DKSNCL32odoQOw31ZhC_XufPxOxtfZcrrvyqM5egFFDXDv2gsk-Zg84GhUm8t91JUG7B9Vq-2Kfx0lKjNmtl68tZIQuL9mGqMhPStadHG3M/s320/Rplot.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Entrez dans la matrice...</td></tr>
</tbody></table>
D'ailleurs, à partir de cette matrice, je me suis amusé à déterminer les trajets les plus grands entre deux pays sur le globe. En voici la liste des 10 premiers, chaque ligne représentant un trajet, dans l'ordre d'importance :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr_rTGtFZg3dxEu01S0erxT7BBoYO6E7Nkc96Flnq9pwDBrAWezTNKW76zmKrl372aAVuOVRjXGN6ul6iuGiVZ9DVipp3uxhq5IZisWwXP-0fv40iBULyLpDbdxCOy_8hbMtye3FBqjBI/s1600/pays+eloignes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="174" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr_rTGtFZg3dxEu01S0erxT7BBoYO6E7Nkc96Flnq9pwDBrAWezTNKW76zmKrl372aAVuOVRjXGN6ul6iuGiVZ9DVipp3uxhq5IZisWwXP-0fv40iBULyLpDbdxCOy_8hbMtye3FBqjBI/s320/pays+eloignes.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
En allant du Paraguay à Taïwan, on parcourt quasiment la moitié de la Terre, la circonférence de cette dernière étant de 40 075 km<br />
<br />
Et voici la carte correspondante pour les 5 plus grands trajets :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl25_TqMSjqZe5RgH2XVo9tZRwOtDqVb5364p6L3rqsBfo17sEzEpUXhFWAKy4_NvX1rnSKVqCU8PUQ-B3tXy07PFDVEHAKmHbk9P1su7fwI420PIPZdUeAaF61Ja9Qh2Dm9uTVlZNaWE/s1600/longues+distances.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="315" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl25_TqMSjqZe5RgH2XVo9tZRwOtDqVb5364p6L3rqsBfo17sEzEpUXhFWAKy4_NvX1rnSKVqCU8PUQ-B3tXy07PFDVEHAKmHbk9P1su7fwI420PIPZdUeAaF61Ja9Qh2Dm9uTVlZNaWE/s640/longues+distances.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
De même, voici la liste des pays les plus "isolés" :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSVjvgD5fGnCUgufqkv__idtv2MpbRm8E0pZuyA2M16eJKtMGlNeo766VwYlPnOkJvEyS0p81MXlNXbArQYch-wvubutSJ6DKdod-gUtBp28kKhEbPHWqc9ENZx0MsnjWVzdAjwVT2cCg/s1600/pays+isol%25C3%25A9s.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSVjvgD5fGnCUgufqkv__idtv2MpbRm8E0pZuyA2M16eJKtMGlNeo766VwYlPnOkJvEyS0p81MXlNXbArQYch-wvubutSJ6DKdod-gUtBp28kKhEbPHWqc9ENZx0MsnjWVzdAjwVT2cCg/s640/pays+isol%25C3%25A9s.png" width="640" /></a></div>
<br />
Revenons à nos moutons...ou plutôt à nos voyageurs de commerce. Maintenant que notre matrice a été constituée, nous pouvons calculer le chemin optimal qui parcourt tous les noeuds une seule fois en cumulant un poids minimal (une distance minimale). Il existe plusieurs méthodes permettant de résoudre la problématique du voyageur de commerce. Dans un premier temps, j'ai tenté la plus commune, la méthode des plus proches voisins, mais elle me trouvait un itinéraire assez bizarre.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtvMV9zmTdTfHmGH9wSIpiMNp24XXyGolw0bNorCUNKCnPZIQ88jxyDY4KrdqeXaOvs4kvm0Xyb6fmzxMSOob3p91nzkmWgZwmGukjXDLF0RXeJ3YQyxVuNFmadB7sCvOyLobRMzzgSqo/s1600/Rplot01.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="376" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtvMV9zmTdTfHmGH9wSIpiMNp24XXyGolw0bNorCUNKCnPZIQ88jxyDY4KrdqeXaOvs4kvm0Xyb6fmzxMSOob3p91nzkmWgZwmGukjXDLF0RXeJ3YQyxVuNFmadB7sCvOyLobRMzzgSqo/s640/Rplot01.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le voyageur de commerce qui avait mal planifié son voyage</td></tr>
</tbody></table>
En fait, c'est normal : la méthode des plus proches voisins prend un point au hasard, détermine le point le plus proche, et répète l'analyse de proche en proche jusqu'à ce que tous les points aient été visités. Une variante prend comme point de départ chaque noeud, compare les tournées, et choisit la meilleure. Cet algorithme est assez basique.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhauiX0AUxtn3hbqu9O2sQH2yl-HIJ1w0irPZWLmxDmSvIBvRDbpgjCTWhKiXZzRJIVoCK_DfcvPxj8JUZHBRXZaJizmvo8aHEuecb9LX7c4_E1Io1MMf-rZsr_htphJL34O_H68kYReg4/s1600/noun_10940_cc.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhauiX0AUxtn3hbqu9O2sQH2yl-HIJ1w0irPZWLmxDmSvIBvRDbpgjCTWhKiXZzRJIVoCK_DfcvPxj8JUZHBRXZaJizmvo8aHEuecb9LX7c4_E1Io1MMf-rZsr_htphJL34O_H68kYReg4/s200/noun_10940_cc.png" width="200" /></a></div>
C'est avec l'algorithme Concorde que j'ai obtenu le meilleur résultat. Voici ce que dit <a href="https://en.wikipedia.org/wiki/Concorde_TSP_Solver" target="_blank">Wikipédia</a> à propos de Concorde :<br />
"a state of the art implementation”<br />
“one of the best exact TSP solvers currently available.”<br />
“is widely regarded as the fastest TSP solver, for large instances, currently in existence".<br />
Bref , il s'agit du voyageur de commerce le plus performant du monde, apparemment. Il doit être milliardaire à l'heure qu'il est !<br />
<br />
Voici donc l'itinéraire que j'ai pu trouver pour parcourir les pays du monde entier, prenant en compte les distances sphériques entre pays. On voit que j'ai aussi inclus l'Antarctique : soyons un peu aventureux !<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjPZsVgU8T2WtmQNtsgmVu8a40-cyKcd0JBgZuDrl2RYbCAiC2dKiHMRXddTmwi965VS2yN3xWU03GcAyS2ukB2E-GsH2ORYpuhKcdFLRGrfZFRpLf9jDJkNM3Vm69nA-O7xMrc-IdD-o/s1600/time+zones.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjPZsVgU8T2WtmQNtsgmVu8a40-cyKcd0JBgZuDrl2RYbCAiC2dKiHMRXddTmwi965VS2yN3xWU03GcAyS2ukB2E-GsH2ORYpuhKcdFLRGrfZFRpLf9jDJkNM3Vm69nA-O7xMrc-IdD-o/s640/time+zones.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Carte avec les fuseaux horaires</td></tr>
</tbody></table>
<br />
<br />
Voici un extrait des pays, dans l'ordre, au moins pour les premiers (ou les derniers, selon le sens où l'on va) :<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3Z-TEetaILp9dWITAw7khUY_QDGGiahT8ekFvyOltwfwWd423pHLXaglbzGi5GEAv2nDoZ7rBChZIkTLjbgxNSOHZ5t3yWS63Nxgd4cC9gXu__KgtAEtWY04ST9Y_cRtJupWXhVEka7w/s1600/destinations.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3Z-TEetaILp9dWITAw7khUY_QDGGiahT8ekFvyOltwfwWd423pHLXaglbzGi5GEAv2nDoZ7rBChZIkTLjbgxNSOHZ5t3yWS63Nxgd4cC9gXu__KgtAEtWY04ST9Y_cRtJupWXhVEka7w/s1600/destinations.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Bon, Corée du Nord, 16e dans la liste, on passe ?</td></tr>
</tbody></table>
<br />
<br />
En distance, en tout, cela représente un peu plus du tiers de la distance Terre-Lune, cette dernière étant de 384 400 km, et entre trois et quatre fois le tour de la Terre<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHvaUozOXgYYHGi6UN_9o9xlKnT2LGHcezJ7H9JWvK6YEkERZpszlKtF6jtBRUmBNI10L5m44VI4tbf7O9AYqDcAMxvCOFvRbZb2u5eqU1gPrssNzx29_uLXeMQGEYXAMVQeDwhOWlHU4/s1600/terre+lune.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHvaUozOXgYYHGi6UN_9o9xlKnT2LGHcezJ7H9JWvK6YEkERZpszlKtF6jtBRUmBNI10L5m44VI4tbf7O9AYqDcAMxvCOFvRbZb2u5eqU1gPrssNzx29_uLXeMQGEYXAMVQeDwhOWlHU4/s1600/terre+lune.png" /></a></div>
<br />
Je me suis demandé combien de temps de vol cela représenterait pour parcourir tout ça. Il existe un site appelé <a href="http://www.travelmath.com/" target="_blank">travelmath</a> qui donne le temps de vol entre tous les pays.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCoYsPdNIMtEhM1703s6v0fDYd7c2aql4eGZxL5niuUGiYqxPLsDl1fGUvuA3GK9t55csdczlOGk6QcNZXgbINON1aLijJmlkE0aqivxz652x-8Hpdf3JvqILRXl4s_vHD_O_Mfitiin8/s1600/travelmath.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="305" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCoYsPdNIMtEhM1703s6v0fDYd7c2aql4eGZxL5niuUGiYqxPLsDl1fGUvuA3GK9t55csdczlOGk6QcNZXgbINON1aLijJmlkE0aqivxz652x-8Hpdf3JvqILRXl4s_vHD_O_Mfitiin8/s400/travelmath.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">(et 11 secondes)</td></tr>
</tbody></table>
<br />
<br />
Avec un petit chouilla de scraping - rien de compliqué - j'ai pu récupérer ces temps tout le long de mon itinéraire, soit pour 176 couples origine-destination. J'ai fait le calcul : il faudrait <b>12 jours !</b> pour effectuer cet itinéraire. En bref, si vous projetez une année sabbatique, ça vous fait un jour à passer dans l'avion par mois en moyenne, pas très reposant...et peu écologique !<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGROzGscR42h1kkDTVIJK8b0z8HPdA3DPnJQom3e2ID-mo29xrxv2S8b1qnW9ybybvsJhsD7XRP_DaX6gg5EkwDeiyicSzYBJPca0bEWpoZpdMzDOxk_mpQwT6NeP_OAKA-U6cpIi4zH8/s1600/12+jours.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="62" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGROzGscR42h1kkDTVIJK8b0z8HPdA3DPnJQom3e2ID-mo29xrxv2S8b1qnW9ybybvsJhsD7XRP_DaX6gg5EkwDeiyicSzYBJPca0bEWpoZpdMzDOxk_mpQwT6NeP_OAKA-U6cpIi4zH8/s640/12+jours.png" width="640" /></a></div>
<br />
<h2>
<span style="color: orange;">Dataventures</span></h2>
Bon, je dois vous avouer qu'utiliser le Concorde (l'algorithme) n'a pas été forcément une mince affaire. Dans un premier temps j'ai testé l'outil Concorde en interface graphique et me suis rendu compte qu'il fournissait des bons résultats :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvaf_KNJNVX4O2WlO0dfGaRAhDZOKJSUt49wpxIJJxgWAY06gGNASRQM3wWune2y2N_AhYuh2iI9AN5lqWh72FIx5y0gbuS3PWP9I5aV1ZtQqcCVNmvM1UcXrwmClcT3Ebb7mb9XOFHn0/s1600/concorde_app.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvaf_KNJNVX4O2WlO0dfGaRAhDZOKJSUt49wpxIJJxgWAY06gGNASRQM3wWune2y2N_AhYuh2iI9AN5lqWh72FIx5y0gbuS3PWP9I5aV1ZtQqcCVNmvM1UcXrwmClcT3Ebb7mb9XOFHn0/s640/concorde_app.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Pas mal !</td></tr>
</tbody></table>
Mais le souci, c'était que visiblement, ce dernier ne prenait en compte que les fichiers de coordonnées, et pas les matrices de poids !..<br />
<br />
J'ai essayé de convertir ma matrice de distances orthodromiques en coordonnées avec un échelonnage multi-dimensionnel et une fonction de R appelée cmdscale, mais cette méthode est loin d'être optimale car j'avais en coordonnées le Cameroun plus proche de la France que la Belgique (!). Ca m'a un peu trotté cette histoire jusqu'à ce que je conclue, bêtement, que cela venait du fait que l'espace dans lequel raisonne cmdscale ne peut prendre en compte la nature sphérique des distances (c'est comme si on était dans une autre dimension avec ma matrice).<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiccq1Y_VW4yf8kxtWy5SpUKC-r3AFtIGcn2hGVduKyI1S1rbs_5JaaOjRyccdh5wwWq9C6JXvg9Rdo47epZcbOrdrylsqyvDLeHFWWILq6syICPgUD3fDVHyl-jZa-PT_148IsNBZs9vg/s1600/cmdscale.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiccq1Y_VW4yf8kxtWy5SpUKC-r3AFtIGcn2hGVduKyI1S1rbs_5JaaOjRyccdh5wwWq9C6JXvg9Rdo47epZcbOrdrylsqyvDLeHFWWILq6syICPgUD3fDVHyl-jZa-PT_148IsNBZs9vg/s320/cmdscale.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Comme un petit problème..</td></tr>
</tbody></table>
<br />
J'ai donc dû me rabattre sur les exécutables source. J'ai téléchargé Concorde <a href="http://www.math.uwaterloo.ca/tsp/concorde.html" target="_blank">depuis un site universitaire canadien</a><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrAiAszirMDihTiRiKWmggwbKRKy-3RfLjCKfkE6zVMkT7ilCldgcb8qpAA6njaIl8dngZovRJyqvxg2VskDbmhFNbKqQQb-Nlnoc0o5kEXUuhNmNOtwmVjSrpfstgC_hsc4qu7BAYJ-o/s1600/site_univ.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="261" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrAiAszirMDihTiRiKWmggwbKRKy-3RfLjCKfkE6zVMkT7ilCldgcb8qpAA6njaIl8dngZovRJyqvxg2VskDbmhFNbKqQQb-Nlnoc0o5kEXUuhNmNOtwmVjSrpfstgC_hsc4qu7BAYJ-o/s400/site_univ.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le site, qui n'a peut-être jamais crashé, contrairement à son outil éponyme</td></tr>
</tbody></table>
<br />
A noter que la licence ne prévoit qu'une utilisation académique, et non commerciale, malgré le nom de l'algorithme ;-) L'outil est exécutable sous Windows grâce à Cygwin, un émulateur Linux. Du coup, j'ai installé Cygwin en 64 bits. Hors, ça ne fonctionnait pas. Je me suis aperçu après moult recherches que Concorde.exe fonctionnait avec Cygwin 32 bits, et non 64 bits. Bon, finalement, lorsque concorde.exe a affiché l'aide dans l'invite de commandes, j'étais soulagé !<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLLSHg-M0nBfdP3nFx0rLO6Jap29yBGJdlxzwPFOKlw-IZNG17HNDoA5KgZPfvrSsuVgCgGJhiyTOF3bt6cWkAf0gmQKftfCiwutpPGA7wPb1HEm2QOFzTXc1pkLRayTE_1X4Lvhf1sTs/s1600/concorde2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLLSHg-M0nBfdP3nFx0rLO6Jap29yBGJdlxzwPFOKlw-IZNG17HNDoA5KgZPfvrSsuVgCgGJhiyTOF3bt6cWkAf0gmQKftfCiwutpPGA7wPb1HEm2QOFzTXc1pkLRayTE_1X4Lvhf1sTs/s640/concorde2.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">**Alleluïa**</td></tr>
</tbody></table>
<br />
<br />
Une fois tout bien configuré, j'ai pu utiliser Concorde dans R après avoir donné le chemin via concorde_path (youpi !) :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5rQ61yfvcYbNZOT5HdsTQdhACtshpR_HGtKaPGAgta1RGNg9tGBhkztDxzn5d5iLm7jupgIWLOduTcktWmEZulajEh4A7uoZ_BOWDMc0WcHLF5JgG37ldcDnSApoIbPvgxzE3H4FgzbM/s1600/concorde_exe.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5rQ61yfvcYbNZOT5HdsTQdhACtshpR_HGtKaPGAgta1RGNg9tGBhkztDxzn5d5iLm7jupgIWLOduTcktWmEZulajEh4A7uoZ_BOWDMc0WcHLF5JgG37ldcDnSApoIbPvgxzE3H4FgzbM/s640/concorde_exe.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Cool, ça marche. Le rouge, c'est juste un avertissement</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Allez, pour finir, voici des cartes que l'on trouve sur le web, qui donnent le chemin le plus court pour parcourir la planète (pas si éloignées que ça de la mienne) :</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://www.wolfram.com/mathematica/new-in-10/entity-based-geocomputation/find-the-shortest-route-through-the-worlds-capital.html" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://www.wolfram.com/mathematica/new-in-10/entity-based-geocomputation/HTMLImages.en/find-the-shortest-route-through-the-worlds-capital/O_13.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Aller d'une capitale à l'autre selon wolfram</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://www.reddit.com/r/MapPorn/comments/1ir7yn/heres_a_map_of_visiting_all_countries_in_a_single/" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://i.imgur.com/ZYh2nTK.jpg" height="334" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">La réponse était aussi sur reddit, sur le canal "Map Porn"</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: orange;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: orange;">Crédits icônographie</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: orange;">Globe issu de Wikipédia</span></div>
<div class="separator" style="clear: both; text-align: left;">
The Crown, by Oliviu Stolan from NounProject</div>
<div class="separator" style="clear: both; text-align: left;">
The Wing by Alice Noir from NounProject</div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com1tag:blogger.com,1999:blog-9055497882207462476.post-62523664424689636582016-10-27T06:30:00.000-07:002016-10-28T05:01:10.681-07:00Le sport en France métropolitaine et le leurre cartographique<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHuUK1o0XUOveKM1spUxL29fqc2UUsjWF0sw18MY2NgSuQxlM0toolTcp3a-6z50WUMvnALcDFBP0x9G6hbHzpQhceqsZeKxOjToR9C8cnq5HheGCVqQmd4Q5cdx4wOZ_t3zYKsCWrcGo/s1600/extrait.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHuUK1o0XUOveKM1spUxL29fqc2UUsjWF0sw18MY2NgSuQxlM0toolTcp3a-6z50WUMvnALcDFBP0x9G6hbHzpQhceqsZeKxOjToR9C8cnq5HheGCVqQmd4Q5cdx4wOZ_t3zYKsCWrcGo/s200/extrait.png" width="200" /></a></div>
Dans ce post, nous allons voir comment réaliser un leurre cartographique, soit la réalisation d'une carte représentant un territoire totalement façonné par des données. Plus précisément, nous verrons la conception d'un territoire de la pratique sportive par départements en France.&nbsp<br />
<span style="color: orange;"><br /></span>
<br />
<h2>
<b><span style="color: orange;"><br /></span></b></h2>
<b><span style="color: orange;"></span></b><br />
<br />
<a name='more'></a><h2>
<span style="color: orange;"><br /></span></h2>
<h2>
<span style="color: orange;">Territoire physique et territoire vécu</span></h2>
Le territoire physique, tout le monde le connaît. Le paysage se déploie sous nos yeux de façon continue, façonné par des variables non discrètes dans l'espace, à savoir le climat, le relief, etc... Mais le territoire perceptible est-ce il le seul qui existe ?<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL1lSMZn86rF14eE3plaJjwxRQzEfuYcl9aiGXuitGs5Rmk7liF1azeZ0ROyUNfNOm9sQw4wTs1brt62d91CoLCvUd_RwMliB2BMaw8VxnNirEUCNPOqaqNs7ztfu16NyBMNE-LtW_jv8/s1600/nappes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="247" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL1lSMZn86rF14eE3plaJjwxRQzEfuYcl9aiGXuitGs5Rmk7liF1azeZ0ROyUNfNOm9sQw4wTs1brt62d91CoLCvUd_RwMliB2BMaw8VxnNirEUCNPOqaqNs7ztfu16NyBMNE-LtW_jv8/s400/nappes.png" width="400" /></a></div>
Nous pourrions imaginer qu'en surcouche de ce dernier flottent une multitude de nappes géographiques :<br />
celui du patrimoine mémoriel, des références culturelles, historiques, celui des <a href="http://combiendebises.free.fr/" target="_blank">bises</a>, du pain au chocolat ou de la chocolatine...<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://blog.adrienvh.fr/2012/10/16/cartographie-des-resultats-de-chocolatine-ou-pain-au-chocolat/" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="291" src="https://www.slate.fr/sites/default/files/styles/1090x500/public/choco.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Pain au chocolat ou chocolatine par Adrien Van Hamme</td></tr>
</tbody></table>
<br />
Il s'agit des territoires perçus, vécus, ressentis, voire même parfois imaginés. Ils sont révélés par les sondages, les enquêtes d'opinion, sous la forme la plus courante de choroplèthes.<br />
<span style="color: orange;"><br /></span>
<br />
<h3>
<span style="color: orange;">Le sport comme nouveau territoire</span></h3>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.slate.fr/sites/default/files/photos/cartebasket.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="305" src="https://www.slate.fr/sites/default/files/photos/cartebasket.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le basket en France</td></tr>
</tbody></table>
Un article de <a href="https://twitter.com/matamix?lang=fr" target="_blank">matamix</a> sur slate montrait <a href="http://www.slate.fr/story/93121/cartes-france-sport" target="_blank">comment le territoire pouvait se métamorphoser selon la pratique sportive</a>. Ici, des rugueux ? Là, des footeux ? La carte se boursoufle selon ce que l'on pratique.<br />
Dans la continuité de ce travail, je me suis posé la question suivante : considérant la pratique sportive dans les départements, peut-on remanier le territoire selon le sport pratiqué par les français et, ainsi, faire figurer, cote à cote, des départements où l'on pratique à peu près le même sport ?<br />
<span style="color: orange;"><br /></span>
<br />
<h2>
<span style="color: orange;">Réalisation d'un "leurre cartographique"</span></h2>
<h3>
<span style="color: #f1c232;">Intégration du fichier et remaniement du tableau</span></h3>
J'ai donc récupéré <a href="http://www.data.gouv.fr/fr/datasets/recensement-des-licences-et-clubs-aupres-des-federations-sportives-agreees-par-le-ministere-charge-d/" target="_blank">le fichier des licences sportives de 2013</a> depuis data.gouv.fr. C'est celui-ci qu'a également utilisé matamix.<br />
Le fichier recense à la fois les sports olympiques et non olympiques. J'ai choisi de me concentrer seulement sur les sports olympiques.<br />
Le fichier est au format long :<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPSRH0rWgrtdwgSiI5Db9HkXVUu_5fLtDfbVHvl4zAMxIA4e3jHNGDGwctrjNqSPe9V_kedAJ90HZ0s1JaP2PDqfSa8de5EC4jaBvxu5xOvZdTKs3sQb4oBi5e0Y2gBBSNfBsiKyrN2SA/s1600/df.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPSRH0rWgrtdwgSiI5Db9HkXVUu_5fLtDfbVHvl4zAMxIA4e3jHNGDGwctrjNqSPe9V_kedAJ90HZ0s1JaP2PDqfSa8de5EC4jaBvxu5xOvZdTKs3sQb4oBi5e0Y2gBBSNfBsiKyrN2SA/s320/df.png" width="193" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le fichier des licences vu dans le logiciel RStudio</td></tr>
</tbody></table>
Nous n'extrayons que les sports olympiques (dont le code fédé commence par 1).<br />
Il serait davantage intéressant de le convertir au format large. Nous aurions alors une colonne par pratique sportive. Hop, ça y est, on a notre fichier au format large :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWe4AYG7ZnbD43ob4hUjFex9B0XCECXrvUozNHuWvG5LeaUNM5oH9mFFXn6P0Z3QBw62-6nQvHEXbWVem3brncXY9vMhb4QMn1fTTCE3TIH2wJ5iu6fw1weJIGBjysjHS-CLUuKsbTOiQ/s1600/df.cast.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWe4AYG7ZnbD43ob4hUjFex9B0XCECXrvUozNHuWvG5LeaUNM5oH9mFFXn6P0Z3QBw62-6nQvHEXbWVem3brncXY9vMhb4QMn1fTTCE3TIH2wJ5iu6fw1weJIGBjysjHS-CLUuKsbTOiQ/s640/df.cast.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Format large : une ligne par communes et les sports en colonnes</td></tr>
</tbody></table>
<br />
Il nous suffira juste d'agréger les valeurs pour avoir des stats départementales et non communales.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit1VDLRILranavHTb33_AYU7lV2HoeR9AprfQgj4OCiOmcj7n-8eMVlyMrrQwU8L0BnLDdSkVqVrZzL50BBlWpbB5mXAMSn-8O5alK_jebMpf3z7EsmNlg2Jud6RtW1QjdTe2z_0wZifw/s1600/df.agg.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="305" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit1VDLRILranavHTb33_AYU7lV2HoeR9AprfQgj4OCiOmcj7n-8eMVlyMrrQwU8L0BnLDdSkVqVrZzL50BBlWpbB5mXAMSn-8O5alK_jebMpf3z7EsmNlg2Jud6RtW1QjdTe2z_0wZifw/s640/df.agg.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Des stats communales aux stats départementales</td></tr>
</tbody></table>
<span style="color: #f1c232;"><br /></span>
<br />
<h3>
<span style="color: #f1c232;">Remaniement spatial</span></h3>
Chaque département peut être positionné dans un espace de dimensions égales au type de sport. C'est comme si on était dans un graphique non pas avec deux axes abcisse et ordonnée, mais 31 axes correspondant aux 31 sports pratiqués.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1kBI5mkLBgAZUmq7XGQNRTVUgvk-826mvCQrgRLFhk9y-qhLZwczxtAjkdhNBm5swgzhuClutJbIHPe1-FGm99k0Zb7eqbuh_2yshdmylq1nYSlFz7NffL3NdaS9kn9QxjWXWoMUhnNs/s1600/20161028_121403+%25281%2529.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1kBI5mkLBgAZUmq7XGQNRTVUgvk-826mvCQrgRLFhk9y-qhLZwczxtAjkdhNBm5swgzhuClutJbIHPe1-FGm99k0Zb7eqbuh_2yshdmylq1nYSlFz7NffL3NdaS9kn9QxjWXWoMUhnNs/s320/20161028_121403+%25281%2529.png" width="272" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td class="tr-caption" style="font-size: 12.8px;">exemple de 21 points dans un espace à 5 dimensions (<span style="background-color: #fefefe; color: #666666; font-family: "arial" , "georgia" , "verdana"; font-size: 1rem;">♪ </span><span style="font-size: 12.8px;">musique de X Files </span><span style="background-color: #fefefe; color: #666666; font-family: "arial" , "georgia" , "verdana"; font-size: 1rem;">♪</span><span style="font-size: 12.8px;">)</span></td></tr>
</tbody></table>
</td></tr>
</tbody></table>
Ce qui signifie que dans cet espace à 31 dimensions, la distance entre chaque département donne une indication de leur similarité en terme de pratique sportive. Nous calculons la matrice de distance entre chaque département dans cet espace. Le résultat est un tableau de contingence avec la distance euclidienne entre tous les départements dans l'espace considéré.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMr7aZ_856Hi-WJawbUZNzsVRg-DML8nw5ARw1FtC4l_47epcNezwnCyfv-txzQRiuJMne9EhKGHzChduRjybHbHG4F513sCuauVNTPU6QLWaoaC5YLkfeiNz6i5Gjvc86UC0znjRjlFk/s1600/dist.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="257" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMr7aZ_856Hi-WJawbUZNzsVRg-DML8nw5ARw1FtC4l_47epcNezwnCyfv-txzQRiuJMne9EhKGHzChduRjybHbHG4F513sCuauVNTPU6QLWaoaC5YLkfeiNz6i5Gjvc86UC0znjRjlFk/s400/dist.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">matrice des distances (euclidiennes) entre départements selon les sports pratiqués</td></tr>
</tbody></table>
<br />
Et si nous essayions de ramener cet espace de 31 dimensions dans un espace de 2 dimensions X et Y, soit un espace représentable sous forme de carte ? Cela peut être accompli avec la technique de positionnement multidimensionnel qui affectera une position dans l'espace à chacun de nos départements en partant de la distance qui sépare chacun. Voici ce que cela donne :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCjqCadIw5lCSy3wFq4gaYS284MVSrO0VKRgNt0ElYERyoxFv6ZLtfBzDE6T-GjscoA5D4mi4be-Wn8iDfzwlz149MsQqpjoOyC4BrXQDhF18YpLYFPxnO-81ceMMgjX_4Ru_6ghlXSSU/s1600/mds.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="311" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCjqCadIw5lCSy3wFq4gaYS284MVSrO0VKRgNt0ElYERyoxFv6ZLtfBzDE6T-GjscoA5D4mi4be-Wn8iDfzwlz149MsQqpjoOyC4BrXQDhF18YpLYFPxnO-81ceMMgjX_4Ru_6ghlXSSU/s400/mds.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Multi Dimensional Scaling</td></tr>
</tbody></table>
<br />
Si l'on colorie les points de ce graphique et la carte des départements en fonction de leur classe selon la méthode des k-moyennes, on obtient ça :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_mkjP7t8vLRtPtWjFM7j08swa5d1vSvGOv4U85R7a8b0GktvK5Z5mko1XwEh6_-g0ITNr3nTIgFfnzij47RMRA0MLKktLxRG3VydvqWYTp47fwiBi7MsasZHB0HofwbTdl0h6erW82c/s1600/mds_sport.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="336" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk_mkjP7t8vLRtPtWjFM7j08swa5d1vSvGOv4U85R7a8b0GktvK5Z5mko1XwEh6_-g0ITNr3nTIgFfnzij47RMRA0MLKktLxRG3VydvqWYTp47fwiBi7MsasZHB0HofwbTdl0h6erW82c/s640/mds_sport.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">méthode des k-moyennes avec 5 classes selon la pratique sportive</td></tr>
</tbody></table>
<br />
Au positionnement géographique et aux caractéristiques topographiques des départements semblent répondre les classes des k-moyennes. On voit un groupe de départements violet, où prédominent les départements alpins. On voit un groupe vert au Nord comprenant au Sud la Gironde.<br />
<br />
Pour investiguer plus largement la carte et quels sports sont majoritaires dans chaque classe, il aurait fallu faire une moyenne des licenciés par sport, par département et par classe. Nous n'avons pas réalisé ce calcul ici, mais on trouvera à la fin une heatmap qui pourra nous donner satisfaction..<br />
<span style="color: #f1c232;"><br /></span>
<br />
<h3>
<b style="color: #f1c232;">Du nuage de points au faux relief</b></h3>
Pour faire une carte, cela peut amplement suffire..mais s'il s'agit de stimuler l'attention et l'imagination de celui qui lira la carte, il faudra sans doute un peu plus faire d'efforts. Pourquoi ne pas emprunter les codes usuels de la cartographie ?<br />
<br />
Comme l'objectif est de partir d'un territoire pour arriver à un autre, complètement remanié selon des variables fournies en entrée, nous allons tenter de travestir ce modeste graphique X Y en carte, laissant penser que ce territoire existe vraiment.<br />
<br />
Le premier "trick" consiste à transformer ce "nuage" de points en relief. Pour cela, on le convertit en carte de chaleur.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://flic.kr/p/Nxk8Ko" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp5h668UOrXuvKnMMMTc9vqsMdOR6pLU5Ysn_Hwzl4rjo4vzlJGIj2ls2PznNXJSJ_h04RXZgn4J4ZVrSGAgF_7_7vHZab0yVhhpIME85WcDjIstx3ER0eUa7XRfE1IMog5DOXW_U58_A/s400/heat.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">hitmap ! heu, une carte de densité ou de chaleur</td></tr>
</tbody></table>
<br />
Cette carte de chaleur fournit un ersatz de modèle numérique de terrain, auquel on affecte des codes couleur selon l'altitude, qui évoquent successivement la mer, le sable chaud, la montagne et ses forêts.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIGmUFcmIJSohZtaJ0B5sgJ5jDkr7Ki-E5G8RpqWoZB4X5QJF60q4Fls7Z5s2egEZqsKaguGSlu0u9IeAZWDzr_9qAnJMdaG3mAFA2ar7htpVl1as0qwnm6MkwY4gwfCQkEbh21F0Vz-U/s1600/terrain.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIGmUFcmIJSohZtaJ0B5sgJ5jDkr7Ki-E5G8RpqWoZB4X5QJF60q4Fls7Z5s2egEZqsKaguGSlu0u9IeAZWDzr_9qAnJMdaG3mAFA2ar7htpVl1as0qwnm6MkwY4gwfCQkEbh21F0Vz-U/s400/terrain.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Des couleurs choisies avec soin métamorphosent une simple heatmap en archipel</td></tr>
</tbody></table>
<br />
De ce faux MNT, on dérive un ombrage :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3CGEc_a8GBoQFB_DsiLE1JgM3qks0AKvgwry0KNGe4Mc1J2KCD7wPHDvbPn9YiKb6kT8GFfVRO5ad-P5R9D4amJm2asFDUa0PMYfw7uJraC9d7G2sOJonLUPH-bb21QnALDeEqwFhrvw/s1600/ombrage.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3CGEc_a8GBoQFB_DsiLE1JgM3qks0AKvgwry0KNGe4Mc1J2KCD7wPHDvbPn9YiKb6kT8GFfVRO5ad-P5R9D4amJm2asFDUa0PMYfw7uJraC9d7G2sOJonLUPH-bb21QnALDeEqwFhrvw/s400/ombrage.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">De tout MNT et surface continue, on peut dériver un ombrage (hillshade)</td></tr>
</tbody></table>
<br />
On ajoute le relief, l'ombrage avec un peu de transparence, puis les noms de départements. Et voilà : on obtient une "fausse carte" :<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://flic.kr/p/NxkaYw" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="364" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1HbnwfmSTvvhmoOSqBsEQEkEqVXykET_pH7vMZaWSV5Op6RpIpy1RLC0vaF0KhmGALxesWRZK53fR7RLtl3cuId4M9eLDuPR4DGu3cFdoxD-TkfFIcgHYZjY-LxfNZRdhMiYgaaAO2cw/s640/carte_sport2.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">(Cliquez pour voir en grand)</td></tr>
</tbody></table>
<br />
<br />
<h2>
<span style="color: orange;">La heatmap de la pratique sportive</span></h2>
Si vous souhaitez confronter la carte avec les données sportives, voici une heatmap créée sous R et "designée" sous QGIS :<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://flic.kr/p/Nxk8Ko" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvgLReu5UK5Cp7G2-QSMPm8ypmd713fpsElDGkp1o-fvmv6SCTxLvmnN4NMnJzgeQx5Vnpvz4qCRB0BUmbgQzZNS5iKFKcEKLlk41bgvki4YRSOuDgRRfe3cJAnClvCCfWtRGTe0x6LyU/s640/heatmap.png" width="448" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Une heatmap dont le rendu a été fait dans QGIS : si, si !<br />
(cliquer pour voir en grand)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
En fait, c'est un raster que j'ai polygonisé et dont j'ai fait le rendu sous QGIS. Comme quoi on peut tout à fait colorier des graphiques sous QGIS sur la base de données produites sous R. Cette heatmap utilise des données recentrées afin de pouvoir comparer des pratiques sportives minoritaires avec des plus généralisées. Ca pourrait valoir le coup que j'explique comment j'ai produit ça dans un prochain post.<br />
<br />
On peut remarquer sur la carte des choses assez banales, et d'autres plus peu surprenantes :<br />
<ul>
<li>Si les départements alpins, y compris ceux de Corse sont assez proches, Jura et Vosges, bien qu'étant aussi des départements montagneux, sont à part, de mêmes que les Pyr. Orientales.</li>
<li>Val de Marne, Hauts de Seine, Seine Saint Denis sont aussi proches sur cette carte. Essonne, Yvelines et Val d'Oise sont pourtant tout à fait ailleurs. Paris est éloigné du reste.</li>
<li>La Seine-et-Marne partage le même îlot que l'Isère et la Gironde, et avec la heatmap, on voit que l'on y pratique l'aviron et la voile.</li>
<li>Le Nord et le Pas-de-Calais sont fans de hockey sur glace.</li>
</ul>
<br />
Je vous laisse le soin d'apporter vos propres observations...harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-52120674832210900232016-04-04T12:51:00.000-07:002016-04-14T02:09:30.079-07:00Des statistiques et des bulles d'iris qui flottent sur Paris<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiV9qdZ_Lhyv9e6umqIqhP-SBK3-82jCUEjPG70q6I_PsrXCHnupvp0zttXtj3FSjNwiDcKLAIGL38cGhEQoz_UYy5B0EsnbviCQmAYUM_Kx1Q37MzmDcseq66vHFfVGwoexQuuaeIWiDU/s1600/arrondissement+bulle.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiV9qdZ_Lhyv9e6umqIqhP-SBK3-82jCUEjPG70q6I_PsrXCHnupvp0zttXtj3FSjNwiDcKLAIGL38cGhEQoz_UYy5B0EsnbviCQmAYUM_Kx1Q37MzmDcseq66vHFfVGwoexQuuaeIWiDU/s200/arrondissement+bulle.png" width="200" /></a>Cet article traite des cartes avec camemberts, des problèmes que cela pose d'un point de vue graphique, et cartographique. Mais surtout, nous verrons la conception d'une carte socio avec diagrammes, par contour IRIS à Paris, qui s'appuie sur le circle packing. Tout ça en essayant d'être rigolo.<br />
<br />
<br />
<br />
<br />
<br />
<a name='more'></a><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://flic.kr/p/FB6Wfs" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="452" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKDyBseemt2T7Sb-Ie50iBgv25Qeln_TNC4Y6I-mVJ2ggug0br0uSbi-WFcQ82u64AS-bSe2gBk1gjiAuwwP4XvY0Ai1SKV9otwcmN9QGCi68p78_u5Eq4-iAfElm9FWrYM39-KA-dGH4/s640/activites4.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Cliquer sur l'image modes de pour voir en grand</td></tr>
</tbody></table>
<h2>
<span style="color: orange;"><br /></span></h2>
<h2>
<span style="color: orange;">La tarte tatin, c'est bon ...enfin, ça dépend</span></h2>
<h3>
<span style="color: #f1c232;"><br /></span></h3>
<h3>
<span style="color: #f1c232;">Les twix, c'est meilleur que les donuts</span></h3>
<div>
<span style="color: #f1c232;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0e2xpxGWjhoqoQ9lsf1jE_t6CCnlq9yatrCDlbv_p2Kc0lRmy_szFOhdO6RbljJAZ0pqF2ka7u7gYYxg6dEDyU6VeF_yLJaUTdM_KbBDzQTThN5iCRyATpGkwz04y-PGzmoCpyqtckyg/s1600/pies.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="107" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0e2xpxGWjhoqoQ9lsf1jE_t6CCnlq9yatrCDlbv_p2Kc0lRmy_szFOhdO6RbljJAZ0pqF2ka7u7gYYxg6dEDyU6VeF_yLJaUTdM_KbBDzQTThN5iCRyATpGkwz04y-PGzmoCpyqtckyg/s320/pies.png" width="320" /></a></div>
<br />
Les américains, ils disent que les tartes aux pommes, c'est pas bon. En effet, un article de <a href="http://www.businessinsider.com/pie-charts-are-the-worst-2013-6?IR=T" target="_blank">Business Insider</a> affirme qu'il est difficile de se faire une idée des proportions avec les pie charts. C'est pourquoi on en mange autant.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdeJznlwoUTBlp9e39yKJCRoN0c3L2GDFcuceHUwJUyi6qI8bkAEJZPaxEfy9pZrM2x2RwplxWHX5igKRq1aKzwNPeL9SeEUWO7kTlM9HHrHFYVcXy_o1kYrJyaVG5DDJnfzRG1ui4Jmk/s1600/blythedale-camembert-3492_640.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdeJznlwoUTBlp9e39yKJCRoN0c3L2GDFcuceHUwJUyi6qI8bkAEJZPaxEfy9pZrM2x2RwplxWHX5igKRq1aKzwNPeL9SeEUWO7kTlM9HHrHFYVcXy_o1kYrJyaVG5DDJnfzRG1ui4Jmk/s320/blythedale-camembert-3492_640.jpg" width="320" /></a></div>
<br />
En France, on appelle ces pie charts des camemberts... On aurait pu appeler ces graphiques des "quiches lorraines" ou "pizzas 4 fromages" selon ce qu'on préfère. Résidant en Provence, je dirais "pompe à l'huile"<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV-Q-CXut8GMwTQFxrcl2Gtx8JHYrkUShGOHXThKFvWyTD5YuhoRldSXcYBV6HCUE_uA3H91psrs-qMFspZYUe9THUm0Pu9Exc41F_j-Yjux7gD5E0-3Up4LL4pz4m9H2YEw-eJiYRsp8/s1600/fernandel.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="319" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV-Q-CXut8GMwTQFxrcl2Gtx8JHYrkUShGOHXThKFvWyTD5YuhoRldSXcYBV6HCUE_uA3H91psrs-qMFspZYUe9THUm0Pu9Exc41F_j-Yjux7gD5E0-3Up4LL4pz4m9H2YEw-eJiYRsp8/s320/fernandel.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">"Les chiffres sont critiques ! Regardez donc cette pompe à l'huile !"</td></tr>
</tbody></table>
<br />
<h3>
<span style="color: #f1c232;">Une tarte un peu spéciale</span></h3>
<div>
<span style="color: #f1c232;"><br /></span></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj7bsCTGf1Ho8h8WoDPPaAOR146bfCT-BeMZFhfoc4lRBA8LTSt2T-hVlO_czlFAFsJBK55g06O0dJZlH9HZNx0538WUVhRcRndSnqL5grBShsyU73DV2ByYPG_DaSMPE9IVyfqmNYVvg/s1600/pie.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhj7bsCTGf1Ho8h8WoDPPaAOR146bfCT-BeMZFhfoc4lRBA8LTSt2T-hVlO_czlFAFsJBK55g06O0dJZlH9HZNx0538WUVhRcRndSnqL5grBShsyU73DV2ByYPG_DaSMPE9IVyfqmNYVvg/s400/pie.JPG" width="400" /></a></td></tr>
<tr><td class="tr-caption"><span style="font-size: x-small;">http://www.datemplate.com/post_types-of-charts_136702/gende</span></td></tr>
</tbody></table>
<div>
</div>
<div>
<br /></div>
<div>
En fait, la vraie dénomination de ce graphique serait d'après l'illustration ci-dessus des "slice chart".</div>
<div>
<br /></div>
<div>
Si l'on se réfère à cette illustration, la vraie pie chart serait une tarte tellement disproportionnée que tout pâtissier assez audacieux pour en confectionner une se ferait interner.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtNvr31IrbEGo9ASWACHWyhFlcjYvneAL2cd12tHGIutPf9CRUqs_hPRQ6q44vsXOaWwQvnqOxBWz5oJ3swOcxkafrR-DRlKNCSxCsG_bR26Isfj1lKiCKJ8sBYPAD0W10QxZXfeUiaWY/s1600/Spider_Chart2.jpg" imageanchor="1"><img border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtNvr31IrbEGo9ASWACHWyhFlcjYvneAL2cd12tHGIutPf9CRUqs_hPRQ6q44vsXOaWwQvnqOxBWz5oJ3swOcxkafrR-DRlKNCSxCsG_bR26Isfj1lKiCKJ8sBYPAD0W10QxZXfeUiaWY/s400/Spider_Chart2.jpg" width="400" /></a></div>
<div>
<br /></div>
<div>
<div>
Cette pie chart présente en réalité certaines caractéristiques des radar charts, ou encore spider charts (des arachnophobes dans la salle ?)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRmrFg4ZqaxCesNucIgBqRiQZAY6vbUtiBEGahD9eR11RNdbCkukezsnvTXgDgIAomCR28zDPuXHj-WiVF1TAiKHP6-bBwgqVA3he4YQ69kRKdHd02unTlWo3StRsewB3vBADc2b6dAW0/s1600/nsadonut.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRmrFg4ZqaxCesNucIgBqRiQZAY6vbUtiBEGahD9eR11RNdbCkukezsnvTXgDgIAomCR28zDPuXHj-WiVF1TAiKHP6-bBwgqVA3he4YQ69kRKdHd02unTlWo3StRsewB3vBADc2b6dAW0/s400/nsadonut.png" width="326" /></a></div>
<br />
<br />
Du coup, on pourrait la traduire par <i><b><span style="color: #0b5394;">RADAR PIE CHART ™</span></b></i>, ou "tarte espion" en français.</div>
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxg2kgA7MK_XzPh4Dd7sBSGDTvWY7XIKh-ZmrEsDJgh-WzsdgpklZ93ilRCCUHgwRdpU2waz1IsRCtjx3BrSOZNP8p1-SV2HPpM9ZUlhlJbY2AG-Oagp5uSEY-Ebj4yghUeO6S_SXSafY/s1600/diagrammes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="365" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxg2kgA7MK_XzPh4Dd7sBSGDTvWY7XIKh-ZmrEsDJgh-WzsdgpklZ93ilRCCUHgwRdpU2waz1IsRCtjx3BrSOZNP8p1-SV2HPpM9ZUlhlJbY2AG-Oagp5uSEY-Ebj4yghUeO6S_SXSafY/s400/diagrammes.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
<div>
Ce type de graphique assez bizarroïde présente selon moi certains avantages sur une carte.<br />
En admettant que l'angle de chaque part de tarte espion soit identique, chacune possèdera la même directivité dans l'espace, ce qui facilite les comparaisons. Ce n'est pas le cas avec la tarte maison.</div>
<div>
Evidemment, cela ne marche plus dès lors que l'on fait varier à la fois l'angle des parts et leur longueur. C'est un cas qu'on rencontre assez souvent avec des graphiques car la bidimensionnalité est leur vocation première.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge1mHwFF8d70tBReLYsKHfVyqsEpv6Bn6DvXxdBi4GipgpHVjKstTyabinlKH_21QlbppiOUM_dfy2UhDrO2XYixxNitKlWzPrknO1__j6m6JxIp-a31_HxLMvXA8-S5nG18B62jWLaiM/s1600/clock-499042_1280.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge1mHwFF8d70tBReLYsKHfVyqsEpv6Bn6DvXxdBi4GipgpHVjKstTyabinlKH_21QlbppiOUM_dfy2UhDrO2XYixxNitKlWzPrknO1__j6m6JxIp-a31_HxLMvXA8-S5nG18B62jWLaiM/s200/clock-499042_1280.png" width="200" /></a></div>
<br />
Ces tartes espion peuvent être utiles afin de figurer des variables statistiques discrètes mais aussi continues, par exemple temporelles.<br />
<br />
<h2>
<span style="color: orange;">Bulles de statistiques</span></h2>
<h3>
<span style="color: #f1c232;"><br /></span></h3>
<h3>
<span style="color: #f1c232;">Les iris ne sont pas que des fleurs</span></h3>
L'IGN et l'Insee nous ont gratifiés il n'y a pas si longtemps des <a href="http://professionnels.ign.fr/contoursiris" target="_blank">contours...IRIS ®</a>, l'iris étant le niveau d'agrégation et administratif le plus fin après la parcelle, le bâtiment et le pavé de trottoir.<br />
En liant des données statistiques à ces IRIS, on peut réaliser tout plein d'analyses et de cartes folles et sympas, ce qui explique pourquoi la mise à disposition de ces contours a pas mal excité la géosphère.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8qeC_6YEF_4PNa6rW4qn2ECJXRQmRQD99YsT3yvHH-BWqvd4Pxc3HnQCak1mSPeUx4CGobP92U8mBmLMD8U7pcacmGBD180dQTKsDhlWbAvrpH_ZFt8dtsdDM05tH7viJw22Mb5e-qI4/s1600/cans-1210402_1920.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="228" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8qeC_6YEF_4PNa6rW4qn2ECJXRQmRQD99YsT3yvHH-BWqvd4Pxc3HnQCak1mSPeUx4CGobP92U8mBmLMD8U7pcacmGBD180dQTKsDhlWbAvrpH_ZFt8dtsdDM05tH7viJw22Mb5e-qI4/s320/cans-1210402_1920.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">"retrouvons-nous après un petit flash publicité"</td></tr>
</tbody></table>
Bon, je le dis comme ça : à l'ouverture des données, je m'étais amusé à réaliser une carte des IRIS niveau France entière avec des...iris<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFv3Ij1etMH2b7Fgsc-DTrMyxkS3AF2ErQhPs_8mIM6qG4fB9_LcBJxJy3trh6Qy5lX2T6LSNWl3xG-nb9tAeiMsiN_GYmN4Vw8ZoRzHLphqRtPUYhwb_9m4S8UTjKrIgKakOGMECdt5s/s1600/IRIS_complet.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="504" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFv3Ij1etMH2b7Fgsc-DTrMyxkS3AF2ErQhPs_8mIM6qG4fB9_LcBJxJy3trh6Qy5lX2T6LSNWl3xG-nb9tAeiMsiN_GYmN4Vw8ZoRzHLphqRtPUYhwb_9m4S8UTjKrIgKakOGMECdt5s/s640/IRIS_complet.png" width="640" /></a></div>
<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
</div>
<br />
<h3 style="-webkit-text-stroke-width: 0px; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
<span style="color: #f1c232;">Catégories socio-professionnelles</span></h3>
<blockquote class="twittertweet" datalang="fr">
<div dir="ltr" lang="fr">
L'Insee, acteur historique de l'<a href="https://twitter.com/hashtag/Opendata?src=hash">#Opendata</a> en France <a href="https://t.co/9G7jFHY7N6">https://t.co/9G7jFHY7N6</a> <a href="https://t.co/Ws9Ei9bOYs">pic.twitter.com/Ws9Ei9bOYs</a></div>
@Insee (@InseeFr) <a href="https://twitter.com/InseeFr/status/697034731733405696">9 février 2016</a></blockquote>
<script async="" charset="utf8" src="//platform.twitter.com/widgets.js"></script><br />
C'est fou tout ce qu'on trouve sur le site de l'INSEE, mine de rien. La donnée qui nous intéresse ici est <a href="http://www.insee.fr/fr/themes/detail.asp?reg_id=99&ref_id=infra-activite-resident-12" target="_blank">le fichier Travail-Emploi</a> du recensement général de la population de 2012 à l'Iris. Grâce à ces données, on peut faire des cartes très intéressantes pour se faire une idée, entre quartiers, de la mixité sociale, du mode de déplacement privilégié des riverains : voiture, deux roues, etc<br />
<br />
Illustrons la méthode en nous appuyant sur la première carte à bulles présentée en début de page. Les colonnes du fichier statistique qui ont été utilisées sont :<br />
<br />
<ul>
<li>nombre d'agriculteurs : on en trouve à Paris, si s</li>
<li>nombre d'artisans, commerçants et chefs d'entreprise</li>
<li>nombre de cadres et professions intellectuelles supérieures</li>
<li>nombre personnes occupant des <a href="http://www.insee.fr/fr/methodes/default.asp?page=nomenclatures/pcs2003/n1_4.htm" target="_blank">professions intermédiaires</a></li>
<li>nombre d'<a href="http://www.insee.fr/fr/methodes/default.asp?page=nomenclatures/pcs2003/n1_5.htm" target="_blank">employés</a></li>
<li>nombre d'ouvriers</li>
</ul>
<br />
<h3>
<span style="color: #f1c232;">Quand les diagrammes posent des soucis aux géomaticiens</span></h3>
<div>
Nous pourrions être tentés de représenter ces données sous forme pie charts (camemberts), voire de graphiques à barres (twix).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7H4kzp7ODccBer3VAOtIEYcjSevFkpoYvT63VT7m68HlgehyphenhyphenZqYdishTE7PCllbNtwboXZ4ieRoMv5BRaHHykzjHpqRkYZRQaFpffnK685go3a5Cx_0FP3ijCF7Evm2XKwEOwlmIQ1RM/s1600/overlapping.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="116" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7H4kzp7ODccBer3VAOtIEYcjSevFkpoYvT63VT7m68HlgehyphenhyphenZqYdishTE7PCllbNtwboXZ4ieRoMv5BRaHHykzjHpqRkYZRQaFpffnK685go3a5Cx_0FP3ijCF7Evm2XKwEOwlmIQ1RM/s400/overlapping.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Dans les deux cas, la difficulté vient, à l'échelle de travail qui est assez fine, du phénomène appelé <i>overlapping </i>qu'on appelle recouvrement en français, mais ça fait moins stylé.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI20IVLuKUErC2ipOewOi02qN8tXC3q4Eudxb4OvfWY29Q8_ewKUaLEgya8x9HsWFtoYkCifx5CsXLO2jVy8HFQ4PibcCqrhggvpAqdkJALsjURNGiGF0BSHzDKOwwCDE700q3H4NuvOw/s1600/OVERLAPPING.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI20IVLuKUErC2ipOewOi02qN8tXC3q4Eudxb4OvfWY29Q8_ewKUaLEgya8x9HsWFtoYkCifx5CsXLO2jVy8HFQ4PibcCqrhggvpAqdkJALsjURNGiGF0BSHzDKOwwCDE700q3H4NuvOw/s400/OVERLAPPING.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ça fait over-mal</td></tr>
</tbody></table>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
</div>
<h3>
<span style="color: #f1c232;">L'astuce du jour, le circle packing, ou empaquetage de cercles (on traduit comme on peut)</span></h3>
<div>
<span style="color: #f1c232;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7hxRmTmQXRzIULt6Jag4LNZRbh-DChKGHBCUkOlJ7bKXA122BWnCu1d9trcDV3FI6qngf_ceXU-UUqKMKY5PcOa_J1LqZrYDglFVGu5JFVdiDsMl7DvFcFkmbNsS1tNi5-0hXvC8YpGw/s1600/hand-998958_1280.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="118" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7hxRmTmQXRzIULt6Jag4LNZRbh-DChKGHBCUkOlJ7bKXA122BWnCu1d9trcDV3FI6qngf_ceXU-UUqKMKY5PcOa_J1LqZrYDglFVGu5JFVdiDsMl7DvFcFkmbNsS1tNi5-0hXvC8YpGw/s200/hand-998958_1280.png" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
L'astuce du jour $*♪ TADAM ♪*$ consiste à utiliser la technique du <a href="https://en.wikipedia.org/wiki/Circle_packing" target="_blank">circle packing</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTPA08nkEHjpv2KPtfzgBhvxmnfBUYOW3EIsUjCVVYD9bSA3bEcpxKcTS0V2IS1CgSBcnW_Gn6xgT20AYdFcju9Nf37xoAkrT4xnG_78NgvcLVu9Pg8EzXMORikphox6t7LgBj6Sky6-U/s1600/google+trad.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="211" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTPA08nkEHjpv2KPtfzgBhvxmnfBUYOW3EIsUjCVVYD9bSA3bEcpxKcTS0V2IS1CgSBcnW_Gn6xgT20AYdFcju9Nf37xoAkrT4xnG_78NgvcLVu9Pg8EzXMORikphox6t7LgBj6Sky6-U/s400/google+trad.png" width="400" /></a></div>
<br />
Cette technique que Google traduit par "cercle d'emballage", consiste à répartir le mieux possible des cercles dans un espace de telle sorte qu'aucun ne recouvre l'autre.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCxkCJ0RF_miXDxXIABx2oyQXgVISBmYx590mhqr5OVH4eiwWL78kSj6-AlzrnpKaw9V8GtqYKkIx6lyzJ8oCIbgjgmOc3Vju6XSMGwi3ADUiktnJ5doMFyOBmHUUZhmgpoyTqwigCgvU/s1600/table-386824_1280.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCxkCJ0RF_miXDxXIABx2oyQXgVISBmYx590mhqr5OVH4eiwWL78kSj6-AlzrnpKaw9V8GtqYKkIx6lyzJ8oCIbgjgmOc3Vju6XSMGwi3ADUiktnJ5doMFyOBmHUUZhmgpoyTqwigCgvU/s320/table-386824_1280.jpg" width="320" /></a></div>
<br />
C'est un peu ce qui se passe si vous remplissez à 99% une table de billard de boules et que vous mettez des boules dessus. Ces dernières vont se faufiler, pousser les autres jusqu'à le tout se soit équilibré (mais faut avoir bouché les trous du billard avant).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN58QFWA5CrkLvsdaOmOKnIMagMchXIdnTupZxtI_SlkluTmCYRe4fjZftDeEbJLHdLmzB2liy3a_9C9fEgE3KkqPyoCbvFX4eeLRWScdN4kMGB-zNEFU-gPvO1IboAHRaZUCRfs4XS1o/s1600/dorling3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN58QFWA5CrkLvsdaOmOKnIMagMchXIdnTupZxtI_SlkluTmCYRe4fjZftDeEbJLHdLmzB2liy3a_9C9fEgE3KkqPyoCbvFX4eeLRWScdN4kMGB-zNEFU-gPvO1IboAHRaZUCRfs4XS1o/s400/dorling3.jpg" width="400" /></a></div>
<br />
Son application en cartographie la plus connue s'appelle les cartogrammes de Dorling, du nom de son créateur, Danny Dorling<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.abc.net.au/reslib/201110/r836157_7753998.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://www.abc.net.au/reslib/201110/r836157_7753998.jpg" height="320" width="240" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Danny Dorling (au photomaton ?)<br />
http://www.abc.net.au/4corners/stories/2011/10/04/3331769.htm</td></tr>
</tbody></table>
<h3>
<span style="color: #f1c232;"><br /></span></h3>
<h3>
<span style="color: #f1c232;">A quoi ressemblera ma carte</span></h3>
<div>
<span style="color: #f1c232;"><br /></span></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfZBtPX00DIZD6JwwQBERKn_CkfPQzN7i5IOxS09ufKuNkG4WO8DBXAu7yvuBchRC3DDuKu2IPyywekoFzAXauZU-Bl83_CLTiy0phRbu0myh6PxZfENVuLl8B-MHN7TB5XNN0rJ7gwLs/s1600/mon+diagramme.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="175" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfZBtPX00DIZD6JwwQBERKn_CkfPQzN7i5IOxS09ufKuNkG4WO8DBXAu7yvuBchRC3DDuKu2IPyywekoFzAXauZU-Bl83_CLTiy0phRbu0myh6PxZfENVuLl8B-MHN7TB5XNN0rJ7gwLs/s400/mon+diagramme.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">un méchant diagramme</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
Au niveau de chaque rosace, chaque catégorie se verra affecter une tranche sur le diagramme et cette dernière sera d'autant plus grande qu'il y aura d'employés, ou de cadres, ou d'artisans,...</div>
<br />
<h2>
<span style="color: orange;">La carte</span></h2>
<h3>
<span style="color: #f1c232;"><br /></span></h3>
<h3>
<span style="color: #f1c232;">Le feeling</span></h3>
<div>
<span style="color: #f1c232;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfYLMySEGp5O0MPyXMq_5I1gYl-8s49hLkx9EOPZgo7f-DRULCcZoyQbhOXfLkvCVp7QsqRUaeGW7b0Q3lkf0-eCep0RZWDpKQWNFf7sUJsf-yZiV8fn2-NqyNCX36h8EU87xHZsdYrEo/s1600/soap-bubble-824550_1920.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfYLMySEGp5O0MPyXMq_5I1gYl-8s49hLkx9EOPZgo7f-DRULCcZoyQbhOXfLkvCVp7QsqRUaeGW7b0Q3lkf0-eCep0RZWDpKQWNFf7sUJsf-yZiV8fn2-NqyNCX36h8EU87xHZsdYrEo/s320/soap-bubble-824550_1920.jpg" width="320" /></a></div>
<br />
Et là, dans ma tête, cercle a évoqué "bulles". Des bulles flotteraient au-dessus de la capitale avec des statistiques dedans. Les stats c'est lourd, mais quand elles sont dans des bulles, c'est plus léger.<br />
<br />
<h3>
<span style="color: #f1c232;">Éléments de contexte</span></h3>
<div>
<span style="color: #f1c232;"><br /></span></div>
<div>
<span style="color: #f1c232;"><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicwY7WR9Hjseve7FDswMnIufz32mg-Yq9vAUSQCLUL4_116-G3sLh_qSG0OS0lVEnlHG7hKd-VVQEJaVz8h7QugY_KpuSmM6r8OY8e6UdMV80MLeLcsCY8RFJNOwl10ME02RMgkZ1Tki4/s1600/arrondissements.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="451" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicwY7WR9Hjseve7FDswMnIufz32mg-Yq9vAUSQCLUL4_116-G3sLh_qSG0OS0lVEnlHG7hKd-VVQEJaVz8h7QugY_KpuSmM6r8OY8e6UdMV80MLeLcsCY8RFJNOwl10ME02RMgkZ1Tki4/s640/arrondissements.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 12.8px;">Bon ok, c'est un peu flou, et même très petit</td></tr>
</tbody></table>
</span></div>
<div>
<span style="color: #f1c232;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY6OvqThXQk8gdm7Uf2DbW5f-6ibkt_X3IyTNnLKKQzOesV5ej7Jvt3yYQzhJ_xik0Ziz5SNGl7ja-ICOLRbBn5A1lPCpzccxGuL4_waKgKdvrwcpCgVDWDGoB_oTShIyIw_X-j7b8cG8/s1600/DOF-ShallowDepthofField.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="143" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY6OvqThXQk8gdm7Uf2DbW5f-6ibkt_X3IyTNnLKKQzOesV5ej7Jvt3yYQzhJ_xik0Ziz5SNGl7ja-ICOLRbBn5A1lPCpzccxGuL4_waKgKdvrwcpCgVDWDGoB_oTShIyIw_X-j7b8cG8/s200/DOF-ShallowDepthofField.jpg" width="200" /></a></div>
J'ai positionné la Seine, épine dorsale de la capitale ainsi que les contours d'arrondissements (<a href="http://professionnels.ign.fr/route500" target="_blank">BDROUTE 500 <span style="background-color: white; color: #545454; font-family: "arial" , sans-serif; font-size: x-small; line-height: 18.2px;">®</span></a>) avec un léger flou, pour donner de la profondeur de champ, comme en photographie, ainsi que rejoindre cette idée de légèreté.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfWjE5rLR90uURRdQwnxGzKzA8L4J8eagYl8V8RSnV3ouOP0Q5KNl8PJXC75fgmWnIsUa3_L2NTEF3qmYvv4f5oVDKN8d8W109wfYQLzZqgAuKS4O_hHlQ_oCTrLxlkVwbjulKr2YMxFc/s1600/arrondissement+bulle.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="552" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfWjE5rLR90uURRdQwnxGzKzA8L4J8eagYl8V8RSnV3ouOP0Q5KNl8PJXC75fgmWnIsUa3_L2NTEF3qmYvv4f5oVDKN8d8W109wfYQLzZqgAuKS4O_hHlQ_oCTrLxlkVwbjulKr2YMxFc/s640/arrondissement+bulle.png" width="640" /></a></div>
<br />
L'algorithme de circle packing s'est chargé du mieux qu'il a pu, de répartir les boules de même circonférence sur le territoire, alors que les iris ont initialement des formes, surfaces différentes, il faut faire attention à l'échelle d'analyse.<br />
Chaque bulle a la couleur d'un arrondissement. Cela est d'autant plus nécessaire que la limite imposée à l'algorithme en terme d'itérations a pu entraîner par endroits le transfert d'une bulle dans un arrondissement voisin.<br />
<br />
Parlez arrondissement à un provincial comme moi, et il n'y pigera que nenni. Parlez-lui métro, et tout s'éclaire. Tout touriste parviendra à adjoindre une atmosphère à une bouche de métro. Les noms "Barbès", "Porte d'Italie", "Le Trocadéro", "La Défense" évoquent tout de suite des ambiances, des souvenirs.<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
Les stations de métro fournissent un très bon référentiel que j'ai choisi d'ajouter en filigrane afin de relier l'environnement socio-professionnel à ce réseau auquel on se réfère souvent.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://upload.wikimedia.org/wikipedia/fr/thumb/0/01/RATP.svg/langfr-220px-RATP.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://upload.wikimedia.org/wikipedia/fr/thumb/0/01/RATP.svg/langfr-220px-RATP.svg.png" width="200" /></a></div>
<br />
La couleur des lignes, des étiquettes est celle du logo de la RATP. Fallait bien choisir une couleur et la couleur peut évoquer une fonction.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW4UjB9hxRex50-h-Nk2gBPi8N2H60SPyU817iG6PK6USHxjIqr0xQB0tSn4RRDnO6yatlXN9NmPJ6m-AR7jg3Il2ClkEfWYKuIrCftimc9apfUp4iV-gNKX8DdOipatjiw1PTnR3vz3o/s1600/metro.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW4UjB9hxRex50-h-Nk2gBPi8N2H60SPyU817iG6PK6USHxjIqr0xQB0tSn4RRDnO6yatlXN9NmPJ6m-AR7jg3Il2ClkEfWYKuIrCftimc9apfUp4iV-gNKX8DdOipatjiw1PTnR3vz3o/s400/metro.png" width="400" /></a></div>
<br />
<br />
Pour récupérer les lignes ainsi que les stations, j'ai utilisé une petite requête overpass (<a href="https://overpass-turbo.eu/" target="_blank">overpass</a> est un super outil d'interrogation et d'extraction de données OSM par attributs et critères géographiques et non un pass navigo illimité que l'on trouve sur le darknet).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFNd1FmD0pCE_dXOIhD6WIcczZae8agcIBu-JJN4P5549SLw9vosrpTBoWlr9WmChnQL2kO-HCL62q1AiIUJRNqbzNJ2YLecfoEn6TIkQpjqJnVxicoJQ3qYfTrSosZ_ukHEuNR8f_B5k/s1600/iris+et+sous+iris.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="452" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFNd1FmD0pCE_dXOIhD6WIcczZae8agcIBu-JJN4P5549SLw9vosrpTBoWlr9WmChnQL2kO-HCL62q1AiIUJRNqbzNJ2YLecfoEn6TIkQpjqJnVxicoJQ3qYfTrSosZ_ukHEuNR8f_B5k/s640/iris+et+sous+iris.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Les iris et leurs niveaux supérieurs</td></tr>
</tbody></table>
Aussi, les noms d'Iris constituent des toponymes intéressants à faire figurer sur la carte. Cependant, ils sont beaucoup trop nombreux. On trouvera par exemple PERE LACHAISE 1, PERE LACHAISE 2, etc...<br />
<br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;">groupes_iris = <a href="http://inside-r.org/r-doc/base/sub"><span style="color: #003399; font-weight: bold;">sub</span></a><span style="color: #009900;">(</span><span style="color: blue;">"^(.*) ([0-9]+)$"</span><span style="color: #339933;">,</span> <span style="color: blue;">"<span style="color: #000099; font-weight: bold;">\\</span>1"</span><span style="color: #339933;">,</span> iris.df$NOM_IRIS<span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
Grâce à une petite expression régulière, j'ai récupéré la racine du nom de l'iris sans le numéro et constitué une couche agrégée d'entités de niveau supérieur. Les noms de ces entités supérieures ont servi à l'étiquetage. Je leur ai affecté la même couleur que celle de l'arrondissement auquel ils appartiennent.<br />
<br />
<h3>
<span style="color: #f1c232;">Bribes de design</span></h3>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
D'un point de vue programmatique, pour générer ces diagrammes, je me suis appuyé sur la librairie R <a href="https://cran.r-project.org/web/packages/packcircles/index.html" target="_blank">packcircles</a> et des rudiments de géométrie.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhophvFTp3E5nTA5IfYpQYBaxDtPvE8R2M60OOwlo_qPfwqyc2kPGX21kay9zEAZKJKG9dwWQQmfLke0ATWhfciiR8gmxhQBzGdiS5ONf3VxTI1OPx83btCxzY2T0K1cnwChvJJszv23ZA/s1600/00000001.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="243" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhophvFTp3E5nTA5IfYpQYBaxDtPvE8R2M60OOwlo_qPfwqyc2kPGX21kay9zEAZKJKG9dwWQQmfLke0ATWhfciiR8gmxhQBzGdiS5ONf3VxTI1OPx83btCxzY2T0K1cnwChvJJszv23ZA/s320/00000001.jpg" width="320" /></a></div>
<br />
<br />
En particulier, pour avoir une tranche de gâteau, il suffit de générer un polygone issu d'une série de points, elle-même définie en fonction d'une distance à un centroïde, d'un effectif et d'une rangée d'angles.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5hQaQ7ngNuEFFonN_O_1kGhEzoXPdWLFDOHg7NnNjCw6ZA2YLAHNmWzkXtW9WJtH4Q6OF5JRdKQDB-P4IZYyKyvuG1Z7CNges6amwKEg2H5nOyRJDvlcre85ylPAm7qAoFWK5zqze1qI/s1600/symboles.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="315" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5hQaQ7ngNuEFFonN_O_1kGhEzoXPdWLFDOHg7NnNjCw6ZA2YLAHNmWzkXtW9WJtH4Q6OF5JRdKQDB-P4IZYyKyvuG1Z7CNges6amwKEg2H5nOyRJDvlcre85ylPAm7qAoFWK5zqze1qI/s400/symboles.png" width="400" /></a></div>
<br />
Sous QGIS, un mode est utilisé, qui de son joli nom "Flannery", permet de définir de façon automatique la taille de symboles proportionnels. Ce mode se base sur une fonction interne de QGIS appelée scale_exp. D'après la<a href="http://docs.qgis.org/2.0/fr/docs/user_manual/working_with_vector/field_calculator.html" target="_blank"> documentation utilisateur officielle de QGIS</a>, cette fonction échelonne des valeurs entre une valeur minimale et une maximale en suivant une courbe exponentielle.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg9llPygOPhHbYO0DIAeUmi5HbXyrtkIhAzNiog8FD5yCwFdyB5d4lc3dKiwL4b5H0ICmJN34S_HuhGXs663nhNpHuJSh1cD9BOMG6Uv5c-dJApI5bzczC7bTFFUfHd3s_6uFgFPgo8UA/s1600/fonctionexp.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg9llPygOPhHbYO0DIAeUmi5HbXyrtkIhAzNiog8FD5yCwFdyB5d4lc3dKiwL4b5H0ICmJN34S_HuhGXs663nhNpHuJSh1cD9BOMG6Uv5c-dJApI5bzczC7bTFFUfHd3s_6uFgFPgo8UA/s640/fonctionexp.png" width="640" /></a></div>
<br />
J'ai porté le code sous R grâce à <a href="http://qgis.org/api/qgsexpression_8cpp_source.html#l00575" target="_blank">la doc' API de QGIS</a> pour définir la taille des pales de la rosace.<br />
<i><span style="font-size: x-small;">Il s'avère qu'en réalité, le rééchelonnage des valeurs se fait selon une courbe de puissance. La fonction devrait du coup plutôt s'appeler scale_pow.</span> </i><br />
Voici une illustration de ce que cette fonction accomplit :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMF3DPsDFiA_vTSNMhEsvogbo-POiUsODmP3acVM6R_bZFgQvERzuVTWFg8q_YO8-vuHMcqgj18AjvynDUzeczD7waSTOQhen3RHsXwy6pwRVmgCorYLcJEIvO6eTGqAs_oSw2qWgGZBk/s1600/scaling.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMF3DPsDFiA_vTSNMhEsvogbo-POiUsODmP3acVM6R_bZFgQvERzuVTWFg8q_YO8-vuHMcqgj18AjvynDUzeczD7waSTOQhen3RHsXwy6pwRVmgCorYLcJEIvO6eTGqAs_oSw2qWgGZBk/s640/scaling.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">La fonction puissance permet de mieux dissocier les valeurs hautes</td></tr>
</tbody></table>
<div>
<br />
Si l'on effectue un étirement linéaire, on perçoit moins les différences de valeur :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnSGamOpQ2SBCJ5SGFB6xMF22f1KZAyoGBfMVNMJcZMH_MQFpBXfsU7GL33pXW9prXQR65o_1XaM6hmxPYEfoP2IQeKQiPbkoyQsGjOuoxUgLYccwsHWvtzN7eiibkJgduqSYG7APzRNA/s1600/scale+vs+linear.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="452" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnSGamOpQ2SBCJ5SGFB6xMF22f1KZAyoGBfMVNMJcZMH_MQFpBXfsU7GL33pXW9prXQR65o_1XaM6hmxPYEfoP2IQeKQiPbkoyQsGjOuoxUgLYccwsHWvtzN7eiibkJgduqSYG7APzRNA/s640/scale+vs+linear.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">étirement linéaireVS étirement par puissance</td></tr>
</tbody></table>
<br /></div>
<h3>
<span style="color: #f1c232;">Du QGIS</span></h3>
<div>
<span style="color: #f1c232;"><br /></span></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT5ylzRj2QAxNoQiZNOzyz49mediB20_sNC2VR2zZ4HpWQvmRNJegPR5gsxAGcPgwpPIXAKK6xIuU2ZUh2FfCO9VLNj5dHxWIA8Y4d9TrdA7bcbp70iG_q67zF3Qfg5nOwq2rCwhIw40A/s1600/bulle.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="296" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT5ylzRj2QAxNoQiZNOzyz49mediB20_sNC2VR2zZ4HpWQvmRNJegPR5gsxAGcPgwpPIXAKK6xIuU2ZUh2FfCO9VLNj5dHxWIA8Y4d9TrdA7bcbp70iG_q67zF3Qfg5nOwq2rCwhIw40A/s320/bulle.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Sur cet iris, des employés d'abord. des professions intermédiaires ensuite, des cadres, des ouvriers et des artisans enfin</td></tr>
</tbody></table>
Pour les bulles, j'ai utilisé le dégradé selon la forme, auquel j'ai ajouté un effet d'ombre intérieure.<br />
J'ai utilisé l'effet flou ainsi que des ombres portées sur les autres éléments d'habillage.<br />
Pour les pétales de la rosace, j'ai utilisé un dégradé simple pour un peu de <a href="https://fr.wikipedia.org/wiki/Skeuomorphisme" target="_blank">skeumorphisme</a> ainsi que des ombres portées.<br />
J'ai également utilisé les modes de fusion, celui de lumière dure et surtout, celui appelé "multiplier".<br />
<br />
<h2>
<span style="color: orange;">Déclinaisons</span></h2>
<h3>
<span style="color: #f1c232;">Paris, encore</span></h3>
On peut décliner ces cartes sur tout un tas d'autres sujets.<br />
<br />
Voici, sur le même mode, la répartition entre étudiants, chômeurs et retraités à Paris par iris:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://flic.kr/p/EYrnpY" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKLnU7hjhsa0qdPkJTaAPtPwTmyEdO7jit0CoNhBKPJS4r-blzoFu2kpGi3v4_0YZhkVfn8BdzPJjdBNHkTxgj5tZdzHcbJ9s6FsiM1ciVztcj28cCxR3V6Xd9ChThCmtemj4pqgmdQnU/s400/chomageEtudiantsRetraites+-+Copie.jpg" width="400" /></a></div>
<br />
Et ici, les modes de déplacement utilisé à Paris : deux roues, voiture, transport collectif, marche à pied :<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://flic.kr/p/FtLo3f" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_hv9Kg5GCakDslWzGGDwOa5x7lZUMW1SWXdB16ZGOyLvsb72EFgC9MxkWYqUQlixKqvzCL9VEx5nnaAh0jgsVkmiCnaUt7Ft8SDbYrLOQAlo4SQmy3nrieBDf6Q0s9NhH335LK4yX4nw/s400/transports+-+Copie.jpg" width="400" /></a></div>
<br />
<h3>
<span style="color: #f1c232;">Bonus tracks</span></h3>
<div>
Allez, en bonus, voici une carte de la population par âge quinquennal, par département</div>
<div>
<span style="font-size: xx-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://flic.kr/p/FYWAdQ" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" height="590" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizRtK3NY9y0irOJ1kfOx5GjDiRwiVwOZqZf6Gje0MJ7hfoDVA-uwBuMP-4YnexKkuEjKppWgbgNgk3Cyj50SZ_QqJcS4OCcMdPGHbBiEQlx97q0l4ICIirht_460lwEfc0sdDIYS_W3gQ/s640/demographieDep.jpg" width="640" /></a></div>
<br />
<div>
A vrai dire, je n'ai rien inventé : des cartes exploitant cette technique ont déjà circulé dans les médias, souvent réalisées à l'échelle internationale ou nationale.</div>
<div>
<span style="color: #f1c232;"><br /></span></div>
<div>
Par exemple, il y a cette <a href="http://www.improving-visualisation.org/vis/id=210" target="_blank">carte </a><a href="http://www.improving-visualisation.org/vis/id=210" target="_blank">de la pollution</a>, issue de l'atlas du carbone :</div>
<div>
<span style="color: #f1c232;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.improving-visualisation.org/img_uploads/2009-05-12_Tue/200951293428.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://www.improving-visualisation.org/img_uploads/2009-05-12_Tue/200951293428.jpg" height="438" width="640" /></a></div>
<div>
<span style="color: #f1c232;"><br /></span></div>
<div>
<a href="http://cartonerd.blogspot.fr/" target="_blank">Kenneth Field</a>, un carto-critique très pertinent, et créateur de cartes originales, avait par exemple créé <a href="http://mapdesign.icaci.org/2014/06/mapcarte-164365-the-beautiful-game-by-kenneth-field-2010/" target="_blank">cette carte</a> à l'occasion du mondial du football</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="http://mapdesign.icaci.org/wp-content/uploads/2014/06/MapCarte164_field.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://mapdesign.icaci.org/wp-content/uploads/2014/06/MapCarte164_field.png" height="449" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 12.8px;">Rond - ballon, il n'y a qu'un pas !</td></tr>
</tbody></table>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com2tag:blogger.com,1999:blog-9055497882207462476.post-44613073904263814322016-03-13T06:27:00.002-07:002016-03-25T14:09:34.939-07:00Le bâti de Paris façon réseau ou comment faire des gribouillis avec R comme avec Processing<br />
<a href="https://flic.kr/p/FeL5UB" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;" target="_blank"><img border="0" height="234" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj5DkI-sjDzt-AiWNmw5x7TFxDFgqCeCJV1Knd8GG7YHYPqUNKg83q7GaRdp6QR4kk0K6sv8-u4Nk5HneH7brjoR3RNu6SUdrnG35JJzMMP8CwAlNGhTuBzdh19q3AFOBldwbJ4KKtMIQ/s320/extrait_liaison3.png" width="320" /></a>Paris sous forme de réseau. Non, on ne parle pas de rues, mais de bâti. Dans cet article, nous proposerons le passage d'une représentation à plat des bâtiments en une figuration sous forme de lignes, aux multiples évocations. On verra qu'avec R, on peut faire certaines choses comme Processing, l'outil de référence en design génératif.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h2>
</h2>
<div>
<a name='more'></a></div>
<h2>
<span style="color: orange;">La carte</span></h2>
<div>
<span style="color: orange;"><br /></span></div>
<div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://flic.kr/p/FeL5UB" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="450" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5x-cFxaaTbepFqXz2npH2O7h8bBreyc-7TzwjhjQ6Lrml77JOPoq2JGPhwU2L5aMm7k3K-gXm9Babt4haXzjy_f1DLtctgW1yOLvRbKQDi8TiRhCh5kbfw0R5Cyx4SgEzahnxxPe3Dko/s640/carte.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Cliquer sur l'image pour la voir en grand sur flickr</td></tr>
</tbody></table>
</div>
<div>
<span style="font-weight: normal;">Sur cette carte est représenté le bâti de Paris sous la forme d'une toile. Chaque point de couleur représente un bâtiment et la couleur de chacun indique la période de construction du bâtiment. </span><br />
<span style="font-weight: normal;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.data.gouv.fr/s/images/e4/bafd4e53c14e378b69a20ce41d23d0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="220" src="https://www.data.gouv.fr/s/images/e4/bafd4e53c14e378b69a20ce41d23d0.png" width="400" /></a></div>
<span style="font-weight: normal;"></span><br />
<span style="font-weight: normal;"><br /></span>
<span style="font-weight: normal;">La rampe de couleurs est celle utilisée par Etienne Côme sur sa carte interactive <a href="http://www.comeetie.fr/galerie/BatiParis/#12/48.8589/2.3491" target="_blank">BATIPARIS</a>.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9khJUQgYFTpWoGNHMbFGP2hqDFbK2Nq9gcBrTXSBe0ORsEzT6Kz2cgvyoOILcDkNkdeyhLU2wkrLGqhrdDHiR4Yvk4iNdSYXk1oj-0L0pJFTe4Rg4QrE7SDyv-fjflAYJLEyHJa52VJA/s1600/interages.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="434" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9khJUQgYFTpWoGNHMbFGP2hqDFbK2Nq9gcBrTXSBe0ORsEzT6Kz2cgvyoOILcDkNkdeyhLU2wkrLGqhrdDHiR4Yvk4iNdSYXk1oj-0L0pJFTe4Rg4QrE7SDyv-fjflAYJLEyHJa52VJA/s640/interages.png" width="640" /></a></div>
<br />
Sur ma carte, un arc relie deux bâtiments et il est d'autant plus clair qu'il relie deux bâtiments de périodes de construction différentes.<br />
<br />
Ce mode de visualisation peut être intéressant pour explorer les différences de valeur dans une variable dans un voisinage, comme dans le cas de cette carte de la densité de population en France :<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUcGXLjROsjaQkH9MW0xsmQl7lBwET7O6b3bTG5xOl5ArzMJCsF6i5yVEBr-v8svk5RsheELyDByCdRLnOeuI0qlTjwYHCyWAOxd68IkIW8AYZRiEQkzO0sPALMDrpj7OZ_vMf3-qruQg/s1600/difference_densite.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUcGXLjROsjaQkH9MW0xsmQl7lBwET7O6b3bTG5xOl5ArzMJCsF6i5yVEBr-v8svk5RsheELyDByCdRLnOeuI0qlTjwYHCyWAOxd68IkIW8AYZRiEQkzO0sPALMDrpj7OZ_vMf3-qruQg/s400/difference_densite.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Différence de densité de population au niveau départemental (RGP INSEE 2013)</td></tr>
</tbody></table>
Sur ma carte, en suivant le réseau, on trouve toujours un chemin pour aller d'un bâtiment à un autre, même si l'on part de la place de l'Étoile pour se diriger vers Bercy; ceci a été obtenu grâce à une technique appelée arbre couvrant de poids minimal. Cette représentation a pour objet d'illustrer la densité d'une ville où tout serait interconnecté.<br />
<br /></div>
<h2>
<span style="color: orange;">Paris dresse sa toile</span></h2>
<div>
<span style="color: orange;"><br /></span></div>
La représentation du bâti est le plus souvent faite avec l'emprise des bâtiments, ce qui peut donner de beaux résultats comme celui de <a href="http://www.comeetie.fr/galerie/BatiParis/" target="_blank">BATIPARIS</a>.<br />
Afin d'illustrer l'évolution champignonnesque d'une ville et se départir de cette représentation classique des bâtiments, on pourrait être tentés de représenter cela sous forme de réseau.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu0IDWKyj56US9JgFZfwKQ9gYYYd04JL3JOYJUHMdPobai2SR-YPCXnU3OHZYOBriAHuf4fG4ilRjA0x2kfmgCyDoc7YIAntLh2priZ2LciaY8i7iuiWSw8hi4VvsLdTBf_mw98ZaeoGU/s1600/image.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu0IDWKyj56US9JgFZfwKQ9gYYYd04JL3JOYJUHMdPobai2SR-YPCXnU3OHZYOBriAHuf4fG4ilRjA0x2kfmgCyDoc7YIAntLh2priZ2LciaY8i7iuiWSw8hi4VvsLdTBf_mw98ZaeoGU/s640/image.jpg" width="296" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">toile d'araignée, mycélium et réseau neuronal</td></tr>
</tbody></table>
Sur ma carte, les ramifications qui relient chaque bâtiment peuvent évoquer de multiples choses : les synapses de neurones rappelant les smart cities, les filaments d'un mycélium, voire même, si on regarde tout ça en noir et blanc, une sorte d'écriture qui évoquerait le tissage, au fil du temps, d'un tissu urbain.<br />
<br />
<h2>
<span style="color: orange;">Les données</span></h2>
<div>
<span style="color: orange;"><br /></span></div>
Les données utilisées sont celles de l'<a href="http://www.apur.org/article/donnees-disponibles-open-data" target="_blank">Atelier Parisien d'URbanisme</a> (APUR). Les données de bâti de l'APUR sont très riches. Outre la période de construction, on y trouve l'année de réhabilitation, les caractéristiques de la toiture, la surface d'ensoleillement,...<br />
Une variable est particulièrement intéressante, que nous exploiterons peut-être dans un nouveau post : la hauteur des bâtiments.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoOLkjPQ0GJPGIBKkCibH8Gu9KR6ZCHiNuP4inAw9sbEFIksIxMoIudc-mpoS8_A5nKOzsfxdDpCsfUMghLQWMlqFb4cvUytm-gs7vd1T2BpjA6x1CHNFkxTpo5SWtioJe83D6Zy5EUFA/s1600/table+attributaire.png" imageanchor="1"><img border="0" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoOLkjPQ0GJPGIBKkCibH8Gu9KR6ZCHiNuP4inAw9sbEFIksIxMoIudc-mpoS8_A5nKOzsfxdDpCsfUMghLQWMlqFb4cvUytm-gs7vd1T2BpjA6x1CHNFkxTpo5SWtioJe83D6Zy5EUFA/s640/table+attributaire.png" width="640" /></a><br />
<br />
La colonne que nous avons utilisée est la même que celle utilisée par Etienne Côme dans son application : la colonne C_PERCONST.<br />
<br />
<h2>
<span style="color: orange;">La transformation</span></h2>
<div>
<span style="color: orange;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4U85I8LJFvdt49G_CSdP5kr3o6I7vSbcUh1-qe3bB28XRNOdEgdCIYPXGcLdHDAvss9MbJyUpprBoDH1g9WAdDzjR-_0gLA916NoHBeDGSUtZwVw3CvIHKpyQ0VZhQ15FcF86WGbW1-Y/s1600/R+gen+design.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4U85I8LJFvdt49G_CSdP5kr3o6I7vSbcUh1-qe3bB28XRNOdEgdCIYPXGcLdHDAvss9MbJyUpprBoDH1g9WAdDzjR-_0gLA916NoHBeDGSUtZwVw3CvIHKpyQ0VZhQ15FcF86WGbW1-Y/s640/R+gen+design.png" width="512" /></a></div>
L'illustration ci-dessus, créée par Benedikt Gross, montre le processus en cours lors d'un design de données. Je lui ai juste ajoutée les outils utilisés.<br />
Pour obtenir notre carte, nous avons créé un algorithme exploitant la théorie des graphes ainsi que des techniques de design génératif. Pour ce dernier domaine, Processing constitue l'outil de référence. Il est adopté par nombre de data artists, d'artistes multimédia. Nous verrons grâce à cet article que R permet aussi de faire du design génératif. Néanmoins, pour peindre nos données, nous nous sommes tournés vers un second outil : QGIS, plutôt que R, en raison de capacités graphiques assez particulières.<br />
<br />
Dans un premier temps, les centroïdes des bâtiments ont été générés<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-Y7HeYEI-FcFGaLb2aLkeyQOnkfvTIOExuebzbdX44_kPpqIHr-XrvLKFuLh-bE9N3lHIRKRmCIn6vmURN5jmmMhHwQp2KxEtVWhhXJgGtyD_UrcbRUmVnkY4q7cqJ8tDBQybL3Z8mgs/s1600/0.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-Y7HeYEI-FcFGaLb2aLkeyQOnkfvTIOExuebzbdX44_kPpqIHr-XrvLKFuLh-bE9N3lHIRKRmCIn6vmURN5jmmMhHwQp2KxEtVWhhXJgGtyD_UrcbRUmVnkY4q7cqJ8tDBQybL3Z8mgs/s320/0.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">L'île de la Cité</td></tr>
</tbody></table>
Ensuite, nous avons relié tous ces points grâce à la fonction de <a href="https://fr.wikipedia.org/wiki/Triangulation_de_Delaunay" target="_blank">Delaunay</a><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK50IfrbPLu4KbfIzCWv6dnZcxvx3J8xeC3Cjx5iZglZF4Fhpn-5WsV95XEeI6tiyT0zA6zuv6GPNnRGni1_PxTE1BjesiVfBoFrdiOIc79QxeIl1AhMlWaio4wDnxlsV1L5NudrMshCA/s1600/1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="233" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK50IfrbPLu4KbfIzCWv6dnZcxvx3J8xeC3Cjx5iZglZF4Fhpn-5WsV95XEeI6tiyT0zA6zuv6GPNnRGni1_PxTE1BjesiVfBoFrdiOIc79QxeIl1AhMlWaio4wDnxlsV1L5NudrMshCA/s320/1.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">De l'eau naît</td></tr>
</tbody></table>
J'ai trouvé que le nombre de segments était bien trop grand pour le rendu final. Afin de l'épurer, j'ai utilisé une technique de la théorie des graphes appelée <a href="https://fr.wikipedia.org/wiki/Arbre_couvrant_de_poids_minimal" target="_blank">Arbre couvrant de poids minimal</a>, ou minimum spanning tree en anglais. Cet arbre est tel qu'on peut trouver un chemin entre chaque sommet avec un nombre de branches minimal<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivFFurUTrak3iU-T4k-a6HSLKNt2UzC7goqqz3-g1pD3Sh4s7FtEQddqN1c0IbxLYtTKTqTs55OjK9pouGx2mi0CxZE2uEbon5rLV4xSgsubiHsDfhXlhWYdoRHVL81XrYJkWlGj8AyM0/s1600/2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="232" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivFFurUTrak3iU-T4k-a6HSLKNt2UzC7goqqz3-g1pD3Sh4s7FtEQddqN1c0IbxLYtTKTqTs55OjK9pouGx2mi0CxZE2uEbon5rLV4xSgsubiHsDfhXlhWYdoRHVL81XrYJkWlGj8AyM0/s320/2.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">MST (Minimum Spanning Tree)</td></tr>
</tbody></table>
Les liaisons entre bâtiments étaient selon moi trop rectilignes. Afin d'obtenir quelque chose de plus "smooth", j'ai utilisé <a href="https://fr.wikipedia.org/wiki/Courbe_de_B%C3%A9zier" target="_blank">les courbes de Bézier</a>. C'est une forme visuelle très usitée dans les infographies de réseaux.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpIb2Npqiw-fBjARphu8tiJ8IBAmF0AuOeoNlimaKE_oNw72uBAWN1A83FT6VHXzcQ_AMFy4uHmggDDktbz1aTLiuarP1czn5_AVvFwQgA6XasjT4XnZRJbHovsCr4ONz77MpOFnV5H8s/s1600/3.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpIb2Npqiw-fBjARphu8tiJ8IBAmF0AuOeoNlimaKE_oNw72uBAWN1A83FT6VHXzcQ_AMFy4uHmggDDktbz1aTLiuarP1czn5_AVvFwQgA6XasjT4XnZRJbHovsCr4ONz77MpOFnV5H8s/s320/3.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Avec Bézier, tout devient plus doux</td></tr>
</tbody></table>
<h2>
<span style="color: orange;">
Le style</span></h2>
<div>
<span style="color: orange;"><br /></span></div>
<ul>
<li>J'ai adopté un <b>fonds</b> noir pour mettre en contraste les données. </li>
<li>J'ai posé le <b>réseau </b>de segments avec un petit effet flou, avec le mode de fusion "addition" et une valeur de luminosité différente selon la différence de période reliant deux bâtiments. Grâce au mode addition ajouté entre les objets, les endroits où les segments se superposent semblent s'éclairer.</li>
<li>Par-dessus, j'ai posé les <b>centroïdes </b>de bâtiments coloriés selon la période de construction, avec un mode de fusion "revêtement". Pour rappel, la rampe de couleurs est celle utilisée dans <a href="http://www.comeetie.fr/galerie/BatiParis/#12/48.8589/2.3491" target="_blank">BATIPARIS</a>. J'avais utilisé le mode de fusion "revêtement" pour <a href="http://www.slate.fr/story/96387/orientation-rues-paris-histoire" target="_blank">la carte de l'orientation des rues de Paris</a>. Avec ce mode, c'est comme si on teintait une couche avec les couleurs d'une autre.</li>
<li>Enfin, en dessous, j'ai disposé <b>la Seine</b> afin de donner un contexte. Celle-ci se trouve dans une couleur hors du spectre utilisé pour le bâti, et avec un peu de flou pour donner un côté organique et en atténuer la présence. </li>
</ul>
<br />
J'aurais pu rajouter des données contextuelles supplémentaires mais j'ai préféré garder un côté minimaliste pour cette carte.<br />
<br />
Voici un tableau récapitulant l'agencement des différentes couches dans QGIS avec leur style et leur ordre de superposition :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP71wToln2LDL3OmrcnaKF2LGvtU2B5CLc0wuE54a_qMGwhknAiLWHsn5gBLwqrRU_FQel-w-ap95D4UZcWUsLvtKVbDH3DDWxZRDf2Vq8DW5M-JhLyPexB-rMXwAOyvyWrCY_AKvbD6Q/s1600/styles.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP71wToln2LDL3OmrcnaKF2LGvtU2B5CLc0wuE54a_qMGwhknAiLWHsn5gBLwqrRU_FQel-w-ap95D4UZcWUsLvtKVbDH3DDWxZRDf2Vq8DW5M-JhLyPexB-rMXwAOyvyWrCY_AKvbD6Q/s640/styles.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<h2>
<span style="color: orange;">
Variations</span></h2>
<div>
<span style="color: orange;"><br /></span></div>
J'ai réalisé des petites variations autour de cette carte.<br />
<br />
Tout d'abord, en générant des lots de données par période, on peut voir dans quelles zones Paris a dressé sa Toile au cours du temps. C'est comme si on voyait la signature de chaque époque.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijHzznJjmDFM1_d69xsOuoxHZsjTdJnxGBlbv3545YIqOide1srbAULtik_oNBPFbBYabwJTRGifLKx-ztDLbfazAVxOFPGD9a3tA00Gn4vhcl23YhCGG4D7stbKJpdgRJNV3EMRpdbAM/s1600/output_1.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="472" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijHzznJjmDFM1_d69xsOuoxHZsjTdJnxGBlbv3545YIqOide1srbAULtik_oNBPFbBYabwJTRGifLKx-ztDLbfazAVxOFPGD9a3tA00Gn4vhcl23YhCGG4D7stbKJpdgRJNV3EMRpdbAM/s640/output_1.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Jusqu'en 1800, on construit surtout au centre</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnto_nVhur0aE-3BhmAneypWwVlcOAVbUFPwV71-nJp3C2hB8eSHbm-yJBiORjDkE47ZAn4QFG1KJcMTeuwCaeKnEzsV-Ysg0mgHXiXJJUbvzWHOi9utc644afs1YptexIRrRblRngI4E/s1600/1851-1914.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="472" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnto_nVhur0aE-3BhmAneypWwVlcOAVbUFPwV71-nJp3C2hB8eSHbm-yJBiORjDkE47ZAn4QFG1KJcMTeuwCaeKnEzsV-Ysg0mgHXiXJJUbvzWHOi9utc644afs1YptexIRrRblRngI4E/s640/1851-1914.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-size: 12.8px;">Georges Eugène Hausmann est dans la place. Ca construit à tout va, y compris des places (comme celle de l'Étoile)</span></td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgry6YlI_vW1YCD4RQ0A2pAUk1MkooJe2f-Qpv591OZ5V3J1ooW9jddt5UMPUrycaurYJPbneu-pORPcqu_dixIJi7yeDAcC6TVtX_nAfacZic0zFj8YQhYCQrFhL3Tn53NTWfdv7IlUKY/s1600/1982-1989.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="472" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgry6YlI_vW1YCD4RQ0A2pAUk1MkooJe2f-Qpv591OZ5V3J1ooW9jddt5UMPUrycaurYJPbneu-pORPcqu_dixIJi7yeDAcC6TVtX_nAfacZic0zFj8YQhYCQrFhL3Tn53NTWfdv7IlUKY/s640/1982-1989.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le rythme de construction semble plus modéré dans les 80's, à part peut-être dans le NE de la capitale</td></tr>
</tbody></table>
<h2>
<span style="color: orange;"><br /></span></h2>
<h2>
<span style="color: orange;">Le code</span></h2>
<div>
<span style="color: orange;"><br /></span></div>
<h3>
<span style="color: #3d85c6; font-weight: normal;">Décortiquage</span></h3>
La librairie <a href="https://cran.r-project.org/web/packages/spdep/index.html" target="_blank">spdep</a> a permis de réaliser la<b> <a href="https://fr.wikipedia.org/wiki/Triangulation_de_Delaunay" target="_blank">triangulation de Delaunay</a> </b>:<br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;">coords = coordinates<span style="color: #009900;">(</span>ile_cite<span style="color: #009900;">)</span>
nb = tri2nb<span style="color: #009900;">(</span>coords<span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
ainsi que de calculer l'<a href="https://fr.wikipedia.org/wiki/Arbre_couvrant_de_poids_minimal" style="font-weight: bold;" target="_blank">arbre couvrant de poids minimal</a> :<br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;">nb = tri2nb<span style="color: #009900;">(</span>coords<span style="color: #009900;">)</span>
nbw = nb2listw<span style="color: #009900;">(</span>nb<span style="color: #339933;">,</span> zero.policy = <span style="color: black; font-weight: bold;">FALSE</span><span style="color: #009900;">)</span>
mst.bh <- mstree<span style="color: #009900;">(</span>nbw<span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
J'ai créé une fonction appelée <b>MakeLineFromCoords </b>qui permet de tracer une ligne à partir d'une série de coordonnées. D'ailleurs, je me suis dit qu'elle pouvait être utile pour superposer tout type de graphique en ligne sur des cartes : par exemple, évolution du chômage par département au cours du temps :<br />
<br />
<div>
<span style="font-family: monospace;">makeLineFromCoords <- </span><a href="http://inside-r.org/r-doc/base/function" style="font-family: monospace;"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900; font-family: monospace;">(</span><span style="font-family: monospace;">coords</span><span style="color: #339933; font-family: monospace;">,</span><span style="font-family: monospace;"> i</span><span style="color: #009900; font-family: monospace;">)</span><span style="font-family: monospace;"> </span><span style="color: #009900; font-family: monospace;">{</span><br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"> Sl1 = Line<span style="color: #009900;">(</span>coords<span style="color: #009900;">)</span>
S1 = Lines<span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/list"><span style="color: #003399; font-weight: bold;">list</span></a><span style="color: #009900;">(</span>Sl1<span style="color: #009900;">)</span><span style="color: #339933;">,</span> ID=<a href="http://inside-r.org/r-doc/base/as.character"><span style="color: #003399; font-weight: bold;">as.character</span></a><span style="color: #009900;">(</span>i<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
Sl = SpatialLines<span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/list"><span style="color: #003399; font-weight: bold;">list</span></a><span style="color: #009900;">(</span>S1<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
<a href="http://inside-r.org/r-doc/base/return"><span style="color: #003399; font-weight: bold;">return</span></a><span style="color: #009900;">(</span>Sl<span style="color: #009900;">)</span>
<span style="color: #009900;">}</span></pre>
</div>
</div>
<br />
R inclut une librairie appelée <b><a href="https://cran.r-project.org/web/packages/bezier/index.html" target="_blank">bezier</a> </b>qui, comme son nom l'indique, permet de dessiner...des courbes de Bézier.<br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;">b = bezier<span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/t"><span style="color: #003399; font-weight: bold;">t</span></a>=<a href="http://inside-r.org/r-doc/base/t"><span style="color: #003399; font-weight: bold;">t</span></a> <- <a href="http://inside-r.org/r-doc/base/seq"><span style="color: #003399; font-weight: bold;">seq</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/length"><span style="color: #003399; font-weight: bold;">length</span></a>=<span style="color: #cc66cc;">100</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> p=<a href="http://inside-r.org/r-doc/base/rbind"><span style="color: #003399; font-weight: bold;">rbind</span></a><span style="color: #009900;">(</span>coords<span style="color: #009900;">[</span>from<span style="color: #339933;">,</span> <span style="color: #009900;">]</span><span style="color: #339933;">,</span> midpoint<span style="color: #339933;">,</span> coords<span style="color: #009900;">[</span>to<span style="color: #339933;">,</span> <span style="color: #009900;">]</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
midpoint désigne le point d'ancrage situé entre les deux points à connecter. La position de ce dernier détermine la courbure finale de l'arc. J'ai injecté un peu de hasard dans la position de ce dernier.<br />
Dans un premier temps, j'ai calculé la distance séparant les deux points :<br />
<br />
<span style="font-family: monospace;">d = </span><a href="http://inside-r.org/r-doc/base/sqrt" style="font-family: monospace;"><span style="color: #003399; font-weight: bold;">sqrt</span></a><span style="color: #009900; font-family: monospace;">(</span><span style="color: #009900; font-family: monospace;">(</span><span style="font-family: monospace;">coords</span><span style="color: #009900; font-family: monospace;">[</span><span style="font-family: monospace;">from</span><span style="color: #339933; font-family: monospace;">,</span><span style="font-family: monospace;"> </span><span style="color: #cc66cc; font-family: monospace;">1</span><span style="color: #009900; font-family: monospace;">]</span><span style="font-family: monospace;"> - coords</span><span style="color: #009900; font-family: monospace;">[</span><span style="font-family: monospace;">to</span><span style="color: #339933; font-family: monospace;">,</span><span style="font-family: monospace;"> </span><span style="color: #cc66cc; font-family: monospace;">1</span><span style="color: #009900; font-family: monospace;">]</span><span style="color: #009900; font-family: monospace;">)</span><span style="font-family: monospace;">^</span><span style="color: #cc66cc; font-family: monospace;">2</span><span style="font-family: monospace;"> + </span><span style="color: #009900; font-family: monospace;">(</span><span style="font-family: monospace;">coords</span><span style="color: #009900; font-family: monospace;">[</span><span style="font-family: monospace;">from</span><span style="color: #339933; font-family: monospace;">,</span><span style="font-family: monospace;"> </span><span style="color: #cc66cc; font-family: monospace;">2</span><span style="color: #009900; font-family: monospace;">]</span><span style="font-family: monospace;"> - coords</span><span style="color: #009900; font-family: monospace;">[</span><span style="font-family: monospace;">to</span><span style="color: #339933; font-family: monospace;">,</span><span style="font-family: monospace;"> </span><span style="color: #cc66cc; font-family: monospace;">2</span><span style="color: #009900; font-family: monospace;">]</span><span style="color: #009900; font-family: monospace;">)</span><span style="font-family: monospace;">^</span><span style="color: #cc66cc; font-family: monospace;">2</span><span style="color: #009900; font-family: monospace;">)</span><br />
<br />
Ensuite, j'ai bougé sa position selon certains seuils. Tout d'abord, j'ai calculé un facteur de transformation qui déterminera dans quelle direction se fait le déplacement du point :<br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/base/ifelse"><span style="color: #003399; font-weight: bold;">ifelse</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/stats/runif"><span style="color: #003399; font-weight: bold;">runif</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>-<span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span><span style="color: #339933;"> ></span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> -<span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuw4atJBkpifakaKGv0muxE9RBBo8S5Ywq9oClR07_iuYEFJdiGcR3lf0yZq1RiRDTaj6bmQTMNbrcVMo8MRoPJjNFeJK5p7gifcuc73hMeXn19hhkFb7GvIsvrqDhccp5CK65tuoHot0/s1600/00000001.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="311" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuw4atJBkpifakaKGv0muxE9RBBo8S5Ywq9oClR07_iuYEFJdiGcR3lf0yZq1RiRDTaj6bmQTMNbrcVMo8MRoPJjNFeJK5p7gifcuc73hMeXn19hhkFb7GvIsvrqDhccp5CK65tuoHot0/s400/00000001.jpg" width="400" /></a></div>
<div>
<br /></div>
Ensuite, j'ai appliqué un ratio tel que le point bougera dans un rayon allant du milieu situé entre les deux points à une distance égale au tiers de la distance séparant les deux points.</div>
<div>
<br /></div>
<div>
Voici le code correspondant au déplacement en X :<br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><span style="color: #009900;">(</span>coords<span style="color: #009900; font-family: monospace;">[</span>from<span style="color: #339933; font-family: monospace;">,</span> <span style="color: #cc66cc; font-family: monospace;">1</span><span style="color: #009900; font-family: monospace;">]</span> + coords<span style="color: #009900; font-family: monospace;">[</span>to<span style="color: #339933; font-family: monospace;">,</span> <span style="color: #cc66cc; font-family: monospace;">1</span><span style="color: #009900; font-family: monospace;">]</span><span style="color: #009900; font-family: monospace;">)</span>/<span style="color: #cc66cc; font-family: monospace;">2</span> + <a href="http://inside-r.org/r-doc/base/ifelse" style="font-family: monospace;"><span style="color: #003399; font-weight: bold;">ifelse</span></a><span style="color: #009900; font-family: monospace;">(</span><a href="http://inside-r.org/r-doc/stats/runif" style="font-family: monospace;"><span style="color: #003399; font-weight: bold;">runif</span></a><span style="color: #009900; font-family: monospace;">(</span><span style="color: #cc66cc; font-family: monospace;">1</span><span style="color: #339933; font-family: monospace;">,</span>-<span style="color: #cc66cc; font-family: monospace;">1</span><span style="color: #339933; font-family: monospace;">,</span><span style="color: #cc66cc; font-family: monospace;">1</span><span style="color: #009900; font-family: monospace;">)</span> > <span style="color: #cc66cc; font-family: monospace;">0</span><span style="color: #339933; font-family: monospace;">,</span> <span style="color: #cc66cc; font-family: monospace;">1</span><span style="color: #339933; font-family: monospace;">,</span> -<span style="color: #cc66cc; font-family: monospace;">1</span></pre>
</div>
</div>
<br />
Et celui en Y est similaire :</div>
<div>
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><span style="color: #009900;">(</span>coords<span style="color: #009900;">[</span>from<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">]</span> + coords<span style="color: #009900;">[</span>to<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span>/<span style="color: #cc66cc;">2</span> + <a href="http://inside-r.org/r-doc/base/ifelse"><span style="color: #003399; font-weight: bold;">ifelse</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/stats/runif"><span style="color: #003399; font-weight: bold;">runif</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>-<span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span> > <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> -<span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span> * <a href="http://inside-r.org/r-doc/stats/runif"><span style="color: #003399; font-weight: bold;">runif</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>d/<span style="color: #cc66cc;">3</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<div>
<br /></div>
Au final, le point intermédiaire d'ancrage de la courbe de Bézier se situera ici :<br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;">midpoint = <a href="http://inside-r.org/r-doc/base/c"><span style="color: #003399; font-weight: bold;">c</span></a><span style="color: #009900;">(</span><span style="color: #009900;">(</span>coords<span style="color: #009900;">[</span>from<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">]</span> + coords<span style="color: #009900;">[</span>to<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span>/<span style="color: #cc66cc;">2</span> + <a href="http://inside-r.org/r-doc/base/ifelse"><span style="color: #003399; font-weight: bold;">ifelse</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/stats/runif"><span style="color: #003399; font-weight: bold;">runif</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>-<span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span> > <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> -<span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span> * <a href="http://inside-r.org/r-doc/stats/runif"><span style="color: #003399; font-weight: bold;">runif</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>d/<span style="color: #cc66cc;">3</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span><span style="color: #009900;">(</span>coords<span style="color: #009900;">[</span>from<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">]</span> + coords<span style="color: #009900;">[</span>to<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span>/<span style="color: #cc66cc;">2</span> + <a href="http://inside-r.org/r-doc/base/ifelse"><span style="color: #003399; font-weight: bold;">ifelse</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/stats/runif"><span style="color: #003399; font-weight: bold;">runif</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>-<span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span> > <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> -<span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span> * <a href="http://inside-r.org/r-doc/stats/runif"><span style="color: #003399; font-weight: bold;">runif</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>d/<span style="color: #cc66cc;">3</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
<h3>
<span style="font-weight: normal;"><span style="color: #3d85c6;">
Le code dans son intégralité</span></span></h3>
<div>
<span style="font-weight: normal;"><span style="color: #3d85c6;"><br /></span></span></div>
<div>
<script src="https://gist.github.com/datagistips/86408dc8a267c0ba68f3.js"></script>
<br />
<div>
<span style="font-weight: normal;"><br /></span></div>
</div>
</div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-82277930663659289072016-01-12T10:53:00.000-08:002016-03-25T14:10:44.658-07:00Plongée dans l'absurde de la cartographie<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy3oxu2jhitowTU5MMk51Vs7AKwahPASkMOogodxb-CH1EAYk18lB1GwCQ9Qe4yvJeUmteSkuYoFrjuCX-v-JwZCE21VET1EqHMxxtYQdPzgU7J-Jg9Vvu5_d2YDwKdG9Frbl2KdMY654/s1600/france3d.png" imageanchor="1" style="clear: left; display: inline !important; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy3oxu2jhitowTU5MMk51Vs7AKwahPASkMOogodxb-CH1EAYk18lB1GwCQ9Qe4yvJeUmteSkuYoFrjuCX-v-JwZCE21VET1EqHMxxtYQdPzgU7J-Jg9Vvu5_d2YDwKdG9Frbl2KdMY654/s320/france3d.png" width="320" /></a>
<em style="background-color: white; color: #6a6a6a; font-family: arial, sans-serif; font-size: small; font-style: normal; font-weight: bold; line-height: 18px;">Ç</em>a et là apparaissent sur la Toile des cartes qui revisitent des thématiques a priori banales sous un angle d'approche assez insolite.<br />
<br />
Dans ce billet de début d'année, nous en listerons quelques-unes avant de nous attaquer à la réalisation d'une carte qui soulève les océans et immerge les montagnes.<br />
<br />
Attention, tout ce qui suit ne doit pas toujours êtres pris au premier degré.<br />
<a name='more'></a><br />
<br />
<br />
<br />
<h2>
<span style="color: orange;">Petit cabinet de curiosités cartographiques</span></h2>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://geotribu.net/sites/default/public/public_res/img/articles-blog-rdp/divers/australie.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://geotribu.net/sites/default/public/public_res/img/articles-blog-rdp/divers/australie.jpg" height="212" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le problème, c'est que quand on met la carte dans le "bon" sens, le texte est à l'envers</td></tr>
</tbody></table>
Tout d'abord, présentons des cartes où les pôles sont inversés, le pôle sud en haut et le nord en bas, à l'image de cette carte de l'australien Stuart <a href="http://derrierelescartes.over-blog.com/article-14482580.html" target="_blank">MacArthur</a>. Ce n'est pas parce que ce monsieur s'est pris un boomerang sur la tête que l'idée lui a pris de représenter le monde de cette manière. C'est sans doute afin de <b>partager avec ses concitoyens australiens une vision commune</b> de son pays positionné au centre du monde.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img border="0" src="http://geotribu.net/sites/default/public/public_res/img/articles-blog-rdp/divers/afrique.jpg" height="320" style="margin-left: auto; margin-right: auto;" width="225" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;">L'Afrique, si elle avait échappé à la colonisation</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<span id="goog_1239330523"></span><span id="goog_1239330524"></span><a href="https://www.blogger.com/"></a></div>
<br />
Généralement, pour nous, ce qui est situé en haut a plus de valeur, car plus proche du divin : "Pourquoi s'abaisser à faire ceci ?", "Quelle bassesse !", "C'est de la musique de bas étage", "Aller plus haut" comme disait <a href="https://www.youtube.com/watch?v=6ctrU3bKQDQ" target="_blank">Tina Arena</a>.<br />
Par un jeu de chaises musicales, <a href="http://rachelstrohm.com/2013/07/29/the-colonization-counterfactual/" target="_blank">cette carte assez radicale de l'Afrique</a> permet de <b>remettre en question la place hégémonique des pays du Nord sur les cartes en occupant un espace toujours réservé</b>. Rappeler la grandeur de l'Afrique, faire un pied-de-nez à l'omnipotence du Nord, sont les objectifs poursuivis par l'artiste suédois à l'origine de cette carte.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://geotribu.net/sites/default/public/public_res/img/articles-blog-rdp/divers/africa.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://geotribu.net/sites/default/public/public_res/img/articles-blog-rdp/divers/africa.png" height="188" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Mercator, c'est une sorte de miroir amincissant pour les pays du Sud</td></tr>
</tbody></table>
La carte ci-dessus compare deux systèmes de projection. Des choses intéressantes se produisent quand on passe de l'un à l'autre. On voit que Mercator écrase les pays de l'Hémisphère Sud. C'est un peu "Pousse-toi, que je m'y mette !". Si Mercator rend beaucoup service aux navigateurs, les projections qui conservent les surfaces comme celle de Peeters ont d'autres qualités : comme elles ne conservent pas les angles, elles accroîtraient la mixité des populations en faisant s'échouer les marins un peu partout. Elles sont donc égalitaires en tous points.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img border="0" src="http://geotribu.net/sites/default/public/public_res/img/articles-blog-rdp/divers/usa.PNG" height="320" style="margin-left: auto; margin-right: auto;" width="274" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Au cas où vous aimeriez mener une vie d'ermite en Amérique</td></tr>
</tbody></table>
Cette carte s'attache à présenter <a href="http://www.fastcodesign.com/3029339/infographic-of-the-day/the-us-is-still-47-percent-frontier-sort-of" target="_blank">les endroits, aux USA, qui ne comptent aucun habitant</a>. Ici, on renverse les codes de la cartographie où l'on présente en général des quantités importantes en premier lieu. Et pourtant, si l'on considère que le vide est quantifiable, cette façon d'aborder les choses gagne en cohérence.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://s2.lemde.fr/image/2015/12/14/534x0/4831759_6_7a90_l-absention-par-commune-en-france_7bfbf84101b3fee012c1b27d2791df62.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://s2.lemde.fr/image/2015/12/14/534x0/4831759_6_7a90_l-absention-par-commune-en-france_7bfbf84101b3fee012c1b27d2791df62.png" height="311" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Carte de l'abstention (lors des élections régionales)</td></tr>
</tbody></table>
Et puis, il n'y a pas si longtemps que ça, après le flot usuel de cartes des élections régionales, sont arrivées des <a href="http://www.lemonde.fr/les-decodeurs/article/2015/12/14/regionales-la-carte-de-l-abstention-au-second-tour_4831760_4355770.html" target="_blank">cartes de l'abstention</a> et du vote blanc. Ces cartes qui mettaient en lumière un mouvement invisible, étaient aussi intéressantes que les cartes usuelles, notamment car elles ont pu montrer là où les électeurs s'étaient le plus mobilisés. Comme quoi l'on part d'un inverse pour revenir à l'autre. Au milieu de tous ces retournements infographiques, avouez qu'il y a de quoi perdre la tête.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://geotribu.net/sites/default/public/public_res/img/articles-blog-rdp/divers/steven%20kay.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://geotribu.net/sites/default/public/public_res/img/articles-blog-rdp/divers/steven%20kay.PNG" height="196" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Quitter le plancher océanique pour mettre un pied sur le fonds continental</td></tr>
</tbody></table>
Assez insolite, il y a aussi cette carte du monde où l'auteur a choisi d'<a href="https://www.flickr.com/photos/stevefaeembra/12662730324/" target="_blank">inverser le relief</a>. Les océans dominent alors les continents qui deviennent de vastes lacs. Cette carte, par son point de vue original, parvient à capter l'attention sur le sujet assez banal qu'est la bathymétrie.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXXxzPdW0YBCgTAEjrN6WvFbeX7DvI9GIxUcCa2Jnx4dk_qoVWlol0PqoOslvzV6x-pK4Lfmy7YNbzNUWmLQiAlDOK1j-a2OP4RlQfsFmvm2Qbi-vTDn78NGs4AIY-Sx5TuU6AFi8cZL0/s1600/00000001.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="345" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXXxzPdW0YBCgTAEjrN6WvFbeX7DvI9GIxUcCa2Jnx4dk_qoVWlol0PqoOslvzV6x-pK4Lfmy7YNbzNUWmLQiAlDOK1j-a2OP4RlQfsFmvm2Qbi-vTDn78NGs4AIY-Sx5TuU6AFi8cZL0/s400/00000001.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">retournement de cerveau</td></tr>
</tbody></table>
On voit que l'inversion peut être traitée de deux façons différentes : soit elle s'attache à la <b>thématique</b> en présentant l'opposé de ce que l'on est censés représenter (par exemple l'abstention versus le vote), soit elle s'attache au <b>graphisme</b> en affectant des codes graphiques inconventionnels à ce que l'on veut illustrer (comme associer la couleur de zones urbanisées à des endroits vides de population). L'approche la plus radicale consiste finalement à représenter de façon inversée l'inverse de ce l'on veut représenter. Est-ce que vous me suivez ? Parce que moi je ne suis pas sûr de me suivre moi-même.<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhulbTptzrk96J5qnAHzetyNXamb9B4UWGF3qycA7i-OqOO0aeX_8hx9xGByh5m-2kHTn3Nbr9mKeSOrr8uIwzLxUgk8tSP_ivpOfj0EEreTVwZ_sY0RLk6ZLksq5CrD9HuLuWy3lWHlAQ/s1600/plato.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhulbTptzrk96J5qnAHzetyNXamb9B4UWGF3qycA7i-OqOO0aeX_8hx9xGByh5m-2kHTn3Nbr9mKeSOrr8uIwzLxUgk8tSP_ivpOfj0EEreTVwZ_sY0RLk6ZLksq5CrD9HuLuWy3lWHlAQ/s200/plato.png" width="163" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Platon était parfois renversant</td></tr>
</tbody></table>
Selon moi, l'objectif de ces représentations originales est double. D'une part, <b>on révèle des patterns insoupçonnés en explorant les antipodes</b> ce que l'on était censés rechercher. On cible les outliers, tout ce qui échappe à la trajectoire moribonde d'une régression linéaire. On attire l'attention du public sur des sujets méconnus.<br />
D'autre part, elles permettent de <b>démontrer quelque chose par un raisonnement assez proche de celui par l'absurde</b>. Par exemple, pour arguer à quelqu'un à quel point les océans sont profonds, l'on serait tentés de les transposer en montagnes. Afin de mettre en évidence les zones peu peuplées, on renverse les codes sémiologiques en utilisant les couleurs habituelles des zones peuplées pour les figurer.<br />
<span style="color: orange;"><br /></span>
<br />
<h2>
<span style="color: orange;"><br /></span></h2>
<h2>
<span style="color: orange;">Et si l'on inversait la bathy ?</span></h2>
La carte où l'altitude de la planète avait été inversée m'a inspiré. J'ai tenté de la reproduire.<br />
<br />
Je me suis procuré la donnée <a href="https://www.ngdc.noaa.gov/mgg/global/global.html" target="_blank">ETOPO1</a> du NOAA (National Oceanic and Atmospheric Administration, institution comparable à notre Météo France) qui combine à la fois la bathymétrie et l'altimétrie en tout point du globe avec une résolution d'un degré (environ 100km).<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUsj2Q2g9F7_ZYN5kUr7xLXS_bANqmrpe3srYelwFPSLBrhtwm1IXd4ZakMFk_JQ2fmC9ODxI1d3PEKaMZS1NQMWKGQ1MiXC0a7z-xkPLZrQvSicVYhmcJeYTnI-R7WD-jYQbSokUtN3M/s1600/result.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUsj2Q2g9F7_ZYN5kUr7xLXS_bANqmrpe3srYelwFPSLBrhtwm1IXd4ZakMFk_JQ2fmC9ODxI1d3PEKaMZS1NQMWKGQ1MiXC0a7z-xkPLZrQvSicVYhmcJeYTnI-R7WD-jYQbSokUtN3M/s640/result.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le monde avec le relief inversé</td></tr>
</tbody></table>
J'ai fait ma tambouille avec <a href="https://fr.wikipedia.org/wiki/GRASS_GIS" target="_blank">GRASS-GIS</a> pour inverser l'altitude, rien de compliqué. Voici, ci-dessus, ce que j'ai obtenu. La rampe de couleurs est conçue de telle manière qu'elle puisse évoquer successivement les grands fonds, les lagons, des plages, des falaises blanches de calcaire, du sol nu, de la forêt, et enfin, des sommets enneigés.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkP-2uj8sOtYzIMGT2VwaU9eES0ho425K13hyphenhyphen-kRegLVVO61TVLR9j2GIHRbhl4Pdc7oUpr-UgwXJ9DxYMSL-AbyGL62ML7i8HsHToCkJYm2hDQmCd2yUqhhIhMk5dvNU9OvfLTnl9xiE/s1600/result.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkP-2uj8sOtYzIMGT2VwaU9eES0ho425K13hyphenhyphen-kRegLVVO61TVLR9j2GIHRbhl4Pdc7oUpr-UgwXJ9DxYMSL-AbyGL62ML7i8HsHToCkJYm2hDQmCd2yUqhhIhMk5dvNU9OvfLTnl9xiE/s640/result.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le monde inversé avec un relief inversé</td></tr>
</tbody></table>
Si je vous avais présentés la carte avec le Sud en haut, soit le monde inversé avec le relief inversé, la sensation devient radicalement différente. Déboussolé, on a peu d'éléments sur lesquels se raccrocher : "on a perdu le Nord"<br />
<br />
Voici ci-dessous des rendus générés grâce au plugin <a href="http://www.portailsig.org/content/plugin-qgis-visualisez-facilement-toutes-vos-couches-en-3d-dans-un-navigateur-avec-qgis2thre" target="_blank">QGIS2ThreeJS</a> :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx9SxWf51juIGShsPIACYlFPHZbaKoaYkMZOI1BMYTzYo6Mw7VCaQOMgWtsV1nZVRwr7eszXwWJ8d9ywxteJO8OVkqUeCFdY9yIyrWAS4vMKqXSyPMC-V9D9Au1Y_SSdshfP47jOGZUKw/s1600/france3d.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="472" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx9SxWf51juIGShsPIACYlFPHZbaKoaYkMZOI1BMYTzYo6Mw7VCaQOMgWtsV1nZVRwr7eszXwWJ8d9ywxteJO8OVkqUeCFdY9yIyrWAS4vMKqXSyPMC-V9D9Au1Y_SSdshfP47jOGZUKw/s640/france3d.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Du côté de chez nous</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb3pIbkftsTg1GQK_WT0Ztl_3YHeZSth-uLGIr4-SzEa9Dd3cjchT5OB8Y5XvnmdVXtl0iBs_vek6eNVAUKbRhPHJcRtHbYLsPIDJEOW-luUxah6SZzkfUxY-gfHNuXykP_dBrTLT8AkU/s1600/india3D.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="440" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb3pIbkftsTg1GQK_WT0Ztl_3YHeZSth-uLGIr4-SzEa9Dd3cjchT5OB8Y5XvnmdVXtl0iBs_vek6eNVAUKbRhPHJcRtHbYLsPIDJEOW-luUxah6SZzkfUxY-gfHNuXykP_dBrTLT8AkU/s640/india3D.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Les abysses himalayennes</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOBG9I_2Zi3fljuFkHDYRCsEYwm0sL3SpaejQ0hIbVa_0kVy7Ed2TfV8WxCZkHoOuCjVnPyuzcdKGRNGw7iIAgOsDtIiXOfcGAYf2rDWU_M36dJf_k3TOdC9EcmmdlItlBTT0fm0XddTI/s1600/caraibes3D.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="348" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOBG9I_2Zi3fljuFkHDYRCsEYwm0sL3SpaejQ0hIbVa_0kVy7Ed2TfV8WxCZkHoOuCjVnPyuzcdKGRNGw7iIAgOsDtIiXOfcGAYf2rDWU_M36dJf_k3TOdC9EcmmdlItlBTT0fm0XddTI/s640/caraibes3D.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Les Caraïbes et l'immense plage du Rio Grande</td></tr>
</tbody></table>
<br />
Libre à nous d'imaginer de nouveaux mondes.<br />
<br />
<h2>
<span style="color: orange;">Précisions techniques</span></h2>
Pour calculer l'opposé des valeurs, j'ai simplement exécuté la ligne suivante sous GRASS avec la calculatrice <a href="http://r.mapcalc/">r.mapcalc</a> :<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">r.mapcalc "etopo_opp=-etopo"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: inherit;">Voici la rampe de couleurs utilisée sous QGIS :</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCZulgj4EnOdhZX3vHnqDTwg_xCX3q_yPt08GHOmQ71iFECzb_yUQIvZVicg1dA1_X8lyNlTQhyphenhyphenjUxaMabz-Jwc0N65ct8cxRPvad5C7ri9zIVHZmii0MM-m-R9wr4c-_6wKasgOopwBM/s1600/rampe.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCZulgj4EnOdhZX3vHnqDTwg_xCX3q_yPt08GHOmQ71iFECzb_yUQIvZVicg1dA1_X8lyNlTQhyphenhyphenjUxaMabz-Jwc0N65ct8cxRPvad5C7ri9zIVHZmii0MM-m-R9wr4c-_6wKasgOopwBM/s200/rampe.png" width="181" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Et voilà !</div>
<h2>
<span style="color: orange;"><br /></span></h2>
<h2>
<span style="color: orange;">Crédits</span></h2>
Platon issu de NounProject et réalisé par <a href="https://thenounproject.com/dabid">Dabid J. Pascual</a>harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-69821892727903712482015-12-03T08:11:00.002-08:002016-01-15T02:50:21.977-08:00Corine Disco Cover<a href="https://vimeo.com/148335254" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="101" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOVSuuzVhKJIyiWzjXaktzURbYtgFYawbmyFWIWwz75iuB-yIaV5R1-6H-D5kXmizAMJNWkmB-a_sbD8uBDFY0CZ2AIw5bDVY4nIMBqZo2QEnwTDpIyLW5GnLMMqEFvek2ho64kQWijGE/s200/vimeo.png" width="200" /></a><span style="color: black;">This post is about the making of an experimental video that dives into the land cover of Paris & its surroundings with a hint of RGB magic. </span><br />
<span style="color: black;"><br /></span>
<span style="color: black;">You'll see the purpose of gridding, how to cross a vector and a raster layer in R. Finally we'll cover one of the latest functionnality of QGIS 2.12 : data-defined layer combinations in atlases.</span><br />
<a name='more'></a><br />
<h2>
</h2>
<h2>
<b><span style="color: orange;"><br /></span></b></h2>
<h2>
<b><span style="color: orange;">If the world were square</span></b></h2>
<div>
<b><span style="color: orange;"><br /></span></b></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxT2qVMyX5Ow4MCk_AglbjhxffTfaftX3BoF75wFqcPm86xdIlT6Ls2POlrQOnyoSzN48wGCN2uoDEuIIpTEiXmw0cNyMhC8jDvteAhS4_L1wWg9UyGOvel79pb6yRUKUWdmmgHuKlZq8/s1600/adm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxT2qVMyX5Ow4MCk_AglbjhxffTfaftX3BoF75wFqcPm86xdIlT6Ls2POlrQOnyoSzN48wGCN2uoDEuIIpTEiXmw0cNyMhC8jDvteAhS4_L1wWg9UyGOvel79pb6yRUKUWdmmgHuKlZq8/s320/adm.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">do you prefer ice creams or sandwiches ?</td></tr>
</tbody></table>
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCHukQzWh6bbGdomW6h2u7thNFQ04GX6_-LlNnuhkKguTZIuoQQNaTXzHyCPIxRHIbZVyVCV0VkuOS0YV4piSSCzb8w8U3u3S1wgj12LDWDiF0-GQ17hl3Kiwu2tdIdmqiaIwtbzvE2io/s1600/matrix.jpg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCHukQzWh6bbGdomW6h2u7thNFQ04GX6_-LlNnuhkKguTZIuoQQNaTXzHyCPIxRHIbZVyVCV0VkuOS0YV4piSSCzb8w8U3u3S1wgj12LDWDiF0-GQ17hl3Kiwu2tdIdmqiaIwtbzvE2io/s200/matrix.jpg" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Matrix is the first movie approaching grids</td></tr>
</tbody></table>
Gridding is a way to simplify the representation of data on a large scale. It can be a useful way to "resample" the vision of a territory if you work on bigger units. These units, usually squares, are comparable, on the contrary to administrative units. If you can omit the administrative units, gridding is a way to get an homogeneous view of your territory. The larger your area of interest will be, the bigger the squares from your grid you might configure.<br />
<br />
<br />
<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwjUi3VSUG435NFiojwQyTeiOoami48KYQBxbyv3oiWDkbQUmgjzUsgjYHLjU9JRcUIfNng0TT5QsJKf2vD3ZYzuPg1UOoJetc5IFh_StkdOuijwGCLJjhf7X64z9lEk9EwK6m_QxYg7g/s1600/bees.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="228" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwjUi3VSUG435NFiojwQyTeiOoami48KYQBxbyv3oiWDkbQUmgjzUsgjYHLjU9JRcUIfNng0TT5QsJKf2vD3ZYzuPg1UOoJetc5IFh_StkdOuijwGCLJjhf7X64z9lEk9EwK6m_QxYg7g/s320/bees.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">hexagons look ecologic, triangles ecclesiastic</td></tr>
</tbody></table>
<br />
Also, you could prefer hexagonal units to square units for more harmony. Some prefer triangles. Anyway, the number of possible shapes are limited.<br />
<br />
<h2>
<b><span style="color: orange;">Land Cover of Paris & surroundings</span></b></h2>
I wanted to visualize the land cover of Ile-De-France width a grid. Ile-de-France is a region that includes Paris at its center. Precisely, I decided to study the repartition of urban , agricultural and natural (forests, gardens, etc...) areas, that is 3 variables over the whole area.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-kdu0oJ0Z_n5pg1GLailn12njwDEBr5sQvbXIpkjliqqSe7HBX9Ng3nL21dMPzDmtk2_MH2sACbBad1fSbVXpPUX4Lxkg-JJI0VQklAdDQtQolPGkMZfItlqQ4rcEFHAUJjEHtILZcig/s1600/diagrams.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-kdu0oJ0Z_n5pg1GLailn12njwDEBr5sQvbXIpkjliqqSe7HBX9Ng3nL21dMPzDmtk2_MH2sACbBad1fSbVXpPUX4Lxkg-JJI0VQklAdDQtQolPGkMZfItlqQ4rcEFHAUJjEHtILZcig/s320/diagrams.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">the best diagram I've ever made, even if pie charts are the worst</td></tr>
</tbody></table>
<br />
The question was : how to represent 3 variables at a time on each square unit ? One answer could have been "diagrams", that is pie charts, histograms on the map<br />
But I found it cooler to use an RGB representation.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghqieLRZVjNIknRKXL99E4_t-gZSoNDFgkqO-y3y1UoV4jw9JYsYI6PE0R3GngkqigOctEzCpHshXDRMZtWu7PsSGS9HdyH0VcM058jvcqBa7S4v7D3ixbGYXB2COVuao-ggTA4V6xb84/s1600/rgb.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghqieLRZVjNIknRKXL99E4_t-gZSoNDFgkqO-y3y1UoV4jw9JYsYI6PE0R3GngkqigOctEzCpHshXDRMZtWu7PsSGS9HdyH0VcM058jvcqBa7S4v7D3ixbGYXB2COVuao-ggTA4V6xb84/s400/rgb.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">A Freemason way of seeing data</td></tr>
</tbody></table>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Let's suppose <span style="color: red;"><b>R</b></span> means urban, <b><span style="color: lime;">G</span></b> Natural and <b><span style="color: blue;">B</span></b> Agricultural. If the color of a square approaches <b><span style="color: red;">red</span></b>, then it means urban; if it is <b><span style="color: magenta;">purple</span></b>, it means urban & agricultural areas dominate but not natural; if it is <b><span style="color: #999999;">desaturated</span></b>, it means the 3 types of cover are equally mixed.<br />
<br />
<h2>
<b><span style="color: orange;">The recipe</span></b></h2>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw20JFRuGE206Bedso89fFXUChpvUGuDovIvQLCuSz3EIF1GaSg7JRRarBRhk9_uK-mdPhyyXC4FdPeh88I_fPY6_aocihAajMkWNvhyphenhyphenzetUTz0BpKE7tY_KZWhkyP3-IfgqOMrIazknI/s1600/clc.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="328" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw20JFRuGE206Bedso89fFXUChpvUGuDovIvQLCuSz3EIF1GaSg7JRRarBRhk9_uK-mdPhyyXC4FdPeh88I_fPY6_aocihAajMkWNvhyphenhyphenzetUTz0BpKE7tY_KZWhkyP3-IfgqOMrIazknI/s400/clc.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">I remember a mushroom im my parents'garden had the same shape</td></tr>
</tbody></table>
<br />
For the land cover of Ile-de-France, we have <a href="http://www.statistiques.developpement-durable.gouv.fr/clc/fichiers/" target="_blank">a nice 2012 Corine Land Cover GeoTiff</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBzxBM4BOwWkhHKvBBQHfi8ugmvfQB2v7UF44MrOs7kSdFlDkXHUBKSH0Vy9mjL-h2fULwFtaypfQ9eR-n0mZD6mDPZQwj3GH202u6t-8j4ww1Fd7pRXlFmCzV_9h-T-V5v2oldAUyN_k/s1600/depth.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBzxBM4BOwWkhHKvBBQHfi8ugmvfQB2v7UF44MrOs7kSdFlDkXHUBKSH0Vy9mjL-h2fULwFtaypfQ9eR-n0mZD6mDPZQwj3GH202u6t-8j4ww1Fd7pRXlFmCzV_9h-T-V5v2oldAUyN_k/s320/depth.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Laurent Manadou exploring data</td></tr>
</tbody></table>
I wondered if one could adopt a dynamic view that goes from the global view to the zonal one in a sort of "data diving".<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWbNl8orZqwtuVApwlRvHFddvMgEYBTbc2bZrdCPI0lfXM-Bzuoi4-Rfht4AqQa9E1mPjfSRfUytbK_yEeRZa4yjzMaZEfTnBHacmyXNukdtD-lArujW1lb4W_g02xgSfBhWZS8fxxJRw/s1600/plot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWbNl8orZqwtuVApwlRvHFddvMgEYBTbc2bZrdCPI0lfXM-Bzuoi4-Rfht4AqQa9E1mPjfSRfUytbK_yEeRZa4yjzMaZEfTnBHacmyXNukdtD-lArujW1lb4W_g02xgSfBhWZS8fxxJRw/s320/plot.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">beware of the logarithmic launching pad</td></tr>
</tbody></table>
I wondered what series of sizes to adopt. I decided to generate 100 images. 1km would be the minimum unit and we would reach the BIG square covering all the region, the width of Ile-De-France being precisely 154 451 km according to <a href="http://professionnels.ign.fr/geofla" target="_blank">GÉOFLA</a>. The distribution, as illustrated, will be logarithmic.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1cba3vzIJG8flHfwD3Nccqdk18I383LDyIrYtsrNX5CkDtN2HL6amJF5H3iPSc8ZsoOKM3b0lrT6UzYfn_gg_ygYjIHk6qXJQ-04T5dF9NgEsedvblvjR-kD6qFKnVjW6EBk9rfGuooA/s1600/anim2.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1cba3vzIJG8flHfwD3Nccqdk18I383LDyIrYtsrNX5CkDtN2HL6amJF5H3iPSc8ZsoOKM3b0lrT6UzYfn_gg_ygYjIHk6qXJQ-04T5dF9NgEsedvblvjR-kD6qFKnVjW6EBk9rfGuooA/s400/anim2.gif" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 12.8px;">The same sensation appears when you dive head first in a municipal pool</td></tr>
</tbody></table>
Above is a GIF presenting the different calculation canvases.<br />
<br />
<div align="center">
<iframe allowfullscreen="" frameborder="0" height="354" mozallowfullscreen="" src="https://player.vimeo.com/video/148335254" webkitallowfullscreen="" width="600"></iframe> <br />
<a href="https://vimeo.com/148335254">Dancing on Land Cover</a> from <a href="https://vimeo.com/user46498397">datagistips</a> on <a href="https://vimeo.com/">Vimeo</a>.</div>
<br />
Here is the video with land cover percentages encoded as colors, with reversed order, from the biggest to the smallest unit. The changing colors make it kind of animated dancefloor.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg96PPNfHyxnB96bpd_sv81E6w7-ZvVcCcmOVql7iq4c0CNqpUr_6XVasXzQZ7TYrYWRkCaagtbVgSwt8Iv5FuYW3pPGpwXCb01mwkJpphO4r9iGCPwOHSOKl18bWs5aF-Ye5umphWTmWE/s1600/ninja.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="205" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg96PPNfHyxnB96bpd_sv81E6w7-ZvVcCcmOVql7iq4c0CNqpUr_6XVasXzQZ7TYrYWRkCaagtbVgSwt8Iv5FuYW3pPGpwXCb01mwkJpphO4r9iGCPwOHSOKl18bWs5aF-Ye5umphWTmWE/s400/ninja.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Dataekwondo</td></tr>
</tbody></table>
<br />
This illustration, that I had made for a <a href="http://geotribu.net/node/788" target="_blank">GéoTribu post</a>, illustrates the usual workflow I adopt, from production to design. I generated the distinct grids associated with the land cover percentage values with <a href="https://www.r-project.org/" target="_blank">R</a>. I designed all the layers with <a href="http://www.qgis.org/fr/site/" target="_blank">QGIS</a>. With the same tool, I generated an atlas. With this atlas, I created a video with <a href="https://www.ffmpeg.org/" target="_blank">ffmpeg</a>.<br />
<br />
<h2>
<span style="color: orange;">Technical details</span></h2>
The QGIS part may interest the QGIS fans as it uses a new QGIS 2.12 functionnality : <a href="http://qgis.org/en/site/forusers/visualchangelog212/#feature-data-defined-control-over-map-layers-and-style-presets" target="_blank">data defined control over map layers and style presets</a><br />
<br />
<h3>
<b><span style="color: #3d85c6;">Generation : R</span></b></h3>
I created a function in R that generates a grid. The hack consists in polygonizing a raster layer, of which the resolution determinates the square size :<br />
<div style="overflow: auto;">
<div class="geshifilter" style="background-color: #f8f6f2;">
<pre class="r geshifilter-R" style="font-family: monospace;">creerGrille = <a href="http://inside-r.org/r-doc/base/function"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900;">(</span>pol<span style="color: #339933;">,</span> size=<span style="color: #cc66cc;">50000</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
r = raster<span style="color: #009900;">(</span>extend<span style="color: #009900;">(</span>extent<span style="color: #009900;">(</span>pol<span style="color: #009900;">)</span><span style="color: #339933;">,</span> size<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> res<span style="color: #009900;">(</span>r<span style="color: #009900;">)</span> = size<span style="color: #339933;">;</span> r<span style="color: #009900;">[</span><span style="color: #009900;">]</span>=<span style="color: #cc66cc;">1</span>
grille = rasterToPolygons<span style="color: #009900;">(</span>r<span style="color: #009900;">)</span>
grille = grille<span style="color: #009900;">[</span><a href="http://inside-r.org/r-doc/base/which"><span style="color: #003399; font-weight: bold;">which</span></a><span style="color: #009900;">(</span>gIntersects<span style="color: #009900;">(</span>grille<span style="color: #339933;">,</span> pol<span style="color: #339933;">,</span> byid=T<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <span style="color: #009900;">]</span>
grille = grille<span style="color: #009900;">[</span>-<a href="http://inside-r.org/r-doc/base/which"><span style="color: #003399; font-weight: bold;">which</span></a><span style="color: #009900;">(</span>gTouches<span style="color: #009900;">(</span>grille<span style="color: #339933;">,</span> reg<span style="color: #339933;">,</span> byid=T<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <span style="color: #009900;">]</span>
<a href="http://inside-r.org/r-doc/base/return"><span style="color: #003399; font-weight: bold;">return</span></a><span style="color: #009900;">(</span>grille<span style="color: #009900;">)</span>
<span style="color: #009900;">}</span></pre>
</div>
</div>
<br />
The extract function crosses the vector grid and the 2012 CLC raster. The table function gives the number of pixels of each category :<br />
<div style="overflow: auto;">
<div class="geshifilter" style="background-color: #f8f6f2;">
<pre class="r geshifilter-R" style="font-family: monospace;"> counts = extract<span style="color: #009900;">(</span>clc2<span style="color: #339933;">,</span> grille<span style="color: #339933;">,</span>
method=<span style="color: blue;">"simple"</span><span style="color: #339933;">,</span>
fun=<a href="http://inside-r.org/r-doc/base/function"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900;">(</span>x<span style="color: #339933;">,</span>...<span style="color: #009900;">)</span><a href="http://inside-r.org/r-doc/base/table"><span style="color: #003399; font-weight: bold;">table</span></a><span style="color: #009900;">(</span>x<span style="color: #009900;">)</span><span style="color: #339933;">,</span>
na.rm=T<span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
The prop.table calculates the proportion of urban, natural and agricultural areas :<br />
<div style="overflow: auto;">
<div class="geshifilter" style="background-color: #f8f6f2;">
<pre class="r geshifilter-R" style="font-family: monospace;">RGB = <a href="http://inside-r.org/r-doc/base/round"><span style="color: #003399; font-weight: bold;">round</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/prop.table"><span style="color: #003399; font-weight: bold;">prop.table</span></a><span style="color: #009900;">(</span>counts<span style="color: #009900;">[</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span>:<span style="color: #cc66cc;">3</span><span style="color: #009900;">]</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span>*<span style="color: #cc66cc;">255</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
<h3>
<b><span style="color: #3d85c6;">Design : QGIS</span></b></h3>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUKsPS-mMAfi456NdLxc-FROY7yuY4zRxnGsVHwSALvcxMRQycJ6gIJCgHtXw7JcJ3p4ICeEAJCX525P9FpuSmKYKotNK6MidifQNVW0-IAJQoeAbSDWC1NnNosuxp3sKPEDxRD7L6c5k/s1600/expression.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUKsPS-mMAfi456NdLxc-FROY7yuY4zRxnGsVHwSALvcxMRQycJ6gIJCgHtXw7JcJ3p4ICeEAJCX525P9FpuSmKYKotNK6MidifQNVW0-IAJQoeAbSDWC1NnNosuxp3sKPEDxRD7L6c5k/s400/expression.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 12.8px;">color RGB code from columns, named "R", "G", and "B"</td></tr>
</tbody></table>
An expression defines the color of each square depending on its column values :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsSSQ6MzLclyZsevUYOpjdkgaFWqm33hsaGC4RNYjfI2K9N4OEeJRjmzE6rtq6kT5vw3vDcy13aQvaIhoTNLuwe0qjeaH-w1Jrnp8C0nRVdg12-7GNO7_hduwguoln7X7kkGFq1FjawYM/s1600/multiqml.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="156" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsSSQ6MzLclyZsevUYOpjdkgaFWqm33hsaGC4RNYjfI2K9N4OEeJRjmzE6rtq6kT5vw3vDcy13aQvaIhoTNLuwe0qjeaH-w1Jrnp8C0nRVdg12-7GNO7_hduwguoln7X7kkGFq1FjawYM/s200/multiqml.png" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 12.8px;">MultiQML plugin</td></tr>
</tbody></table>
I saved the QML style file, then used the <a href="https://plugins.qgis.org/plugins/multiqml/" target="_blank">multiQML</a> plugin to apply it to the 99 other layers.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFLREpzkMlLD18zbrfRu5n0-DxkywX1lAm3fjMvB3UjMk-9fVURka0Q5gBYBuPQt54JcAZk__x9bi9d414ytKA2OYj8nU54XcnRYhQ036-3pepQ3UXp7NuGSUwo57ps6_nI5iezrsFCIE/s1600/atlas.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFLREpzkMlLD18zbrfRu5n0-DxkywX1lAm3fjMvB3UjMk-9fVURka0Q5gBYBuPQt54JcAZk__x9bi9d414ytKA2OYj8nU54XcnRYhQ036-3pepQ3UXp7NuGSUwo57ps6_nI5iezrsFCIE/s400/atlas.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 12.8px;">Data defined control over map layers and style presets</td></tr>
</tbody></table>
To get a static coverage layer, I duplicated my area of interest as many times as the number of pages (or layers) and assigned the square size value to the layer names. In the latest version of QGIS, you can generate an atlas with a list of layers on each page defined by an expression.<br />
<br />
Also, I used some <a href="https://en.wikipedia.org/wiki/Generative_Design" target="_blank">generative design</a> tricks to get the animated halo effect around the IDF region.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL2dZ5794k1eUDTEAo4D3-PiEZy4KmBK0E1HsqTA8AjcEd7DAjhtu2I4l0aOBOFTtIBrbb6Cq8v3RR9pDsBlqL0PuLDr68G7_9cFwhh8mOqBMZ98VDqv81m0EzTsvZhk7VIaj-S2XcroY/s1600/color.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL2dZ5794k1eUDTEAo4D3-PiEZy4KmBK0E1HsqTA8AjcEd7DAjhtu2I4l0aOBOFTtIBrbb6Cq8v3RR9pDsBlqL0PuLDr68G7_9cFwhh8mOqBMZ98VDqv81m0EzTsvZhk7VIaj-S2XcroY/s400/color.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Shapeburst fill and data-defined color</td></tr>
</tbody></table>
<br />
The color follows the chromatic color circle, covering all the rainbow colors :<br />
<span style="font-family: "courier new" , "courier" , monospace;">color_hsv(scale_linear(@atlas_featurenumber,1,100,0,360),40,27)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMlchiWvOqBSV_ZMCWdAe2SkhvW-2kcLOI4SiWm3ELzPjXlmuHre9pI9T7WSQWnDPeF7l9gYXXTlPO8O6DoWRtwokstuQ893vaXH6sSLXNuTsGjORCbU2_JjakKw1DHbI-ITis8S78kzM/s1600/sine-wave-zero-offset.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="177" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMlchiWvOqBSV_ZMCWdAe2SkhvW-2kcLOI4SiWm3ELzPjXlmuHre9pI9T7WSQWnDPeF7l9gYXXTlPO8O6DoWRtwokstuQ893vaXH6sSLXNuTsGjORCbU2_JjakKw1DHbI-ITis8S78kzM/s320/sine-wave-zero-offset.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">riding the wave of generative design</td></tr>
</tbody></table>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1tjdWM-L8h4huJlb2VnMnWj6sClywj810vsffgfdvSzAodSnJaoBZsqucQKOB_B1dWQxOt62Fgb_Kt8LO-Yk5h9d9Ik3c_6rWlIYTqilKxq_N1-eaugBlfPkVKiwIQ5t0YMepoPLAHRg/s1600/shade+distance.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="170" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1tjdWM-L8h4huJlb2VnMnWj6sClywj810vsffgfdvSzAodSnJaoBZsqucQKOB_B1dWQxOt62Fgb_Kt8LO-Yk5h9d9Ik3c_6rWlIYTqilKxq_N1-eaugBlfPkVKiwIQ5t0YMepoPLAHRg/s400/shade+distance.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">sin wave shade distance</td></tr>
</tbody></table>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
while a sin function defines the shade distance. This way, we get a "flame" effect with increasing then decreasing shade width.
<span style="font-family: "courier new" , "courier" , monospace;">scale_linear(sin(scale_linear(@atlas_featurenumber,1,100,0,pi()*2)),0,1,5,10)</span>
<br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<br />
<h3>
<b><span style="color: #3d85c6;">Video making: ffmpeg</span></b></h3>
Finally, this command line generates the video from images :<br />
<span style="font-family: "courier new" , "courier" , monospace;">ffmpeg -framerate 25 -r 10 -i output_%d.jpg -vcodec mpeg4 -b 50000k -qscale:v 1 dancingVideo.avi</span><br />
<br />
<h2>
<span style="color: orange;"><b>The code</b></span></h2>
<h3>
<span style="color: #3d85c6;"><b>The functions</b></span></h3>
<script src="https://gist.github.com/datagistips/5faad6f6c665e6b8ad9a.js"></script><br />
<h3>
<span style="color: #3d85c6;"><b>The processing code</b></span></h3>
<script src="https://gist.github.com/datagistips/7110caa1b9c15de769d2.js"></script><br />
<br />
<h2>
<span style="color: orange;">Credits</span></h2>
<div>
Images from <a href="https://thenounproject.com/" target="_blank">The Noun Project</a> : diver <i>by Claire Jones</i>, honey <i>by Angela Horton</i>, sandwich <i>by Gareth Servant</i>, biker <i>by Les vieux garçons</i>, ice cream <i>by Rafaël Massé</i>.</div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-44488798212035371032014-11-15T03:48:00.000-08:002015-12-10T01:55:23.831-08:00Streets of Paris Colored by Orientation<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.flickr.com/photos/10519370@N04/15654896891/" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;" target="_blank"><img border="0" height="134" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY29reF2tt0UKMWTQZkzHqJU4uU_u7F_GZri9mGdIZZibpB9agf8qUe4sfy6S62wrJhJxNWXca32bB0Gi_Pe9iFeUfCyQEyfeG2SD3jUCgBEKplRjvjkn7qqwzQy5_qkr2UBwMWWBkPHE/s1600/paris.jpeg" width="200" /></a></div>
Recently, I read an article by <a href="http://ww.datapointed.net/" target="_blank">datapointed</a> which presented maps of <a href="http://www.datapointed.net/2014/10/maps-of-street-grids-by-orientation/" target="_blank">streets of different cities colored by orientation</a>.<br />
The author gave some details about the method, which I tried to reproduce. In this post, I present the different steps from the calculation in my favorite spatial R ToolBox to the rendering in QGIS using a specific blending mode.<br />
<br />
<div style="text-align: right;">
<i><span style="font-size: xx-small;">The code is given at the end of the article.</span></i><br />
<i style="text-align: left;"><span style="font-size: xx-small;">Data used in this post is from OpenStreetMap contributors :</span></i><br />
<i style="text-align: left;"><span style="font-size: xx-small;">Get it on <a href="http://download.geofabrik.de/" target="_blank">OSM Metro Extract</a> or <a href="http://download.geofabrik.de/" target="_blank">GeoFabrik</a></span></i><br />
<i style="text-align: left;"><br /></i></div>
<div style="text-align: right;">
<span style="font-size: xx-small;"><i></i></span></div>
<a name='more'></a><div style="text-align: right;">
<div style="text-align: left;">
First, polylines are split into lines.<br />
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUVXNbrfvCnjM915AUJ74J1X0vAp-7pHai8sBuqZLeiOKwdZjJJctlSm0qOx2_ieoPJ_oEyVdBrBk01ogYtQROEH7TjiSN5S9JcCsU4q-2vlHfSRazy3zT1Y-2bwd521Jsoq3Z48yprfU/s1600/nodes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="63" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUVXNbrfvCnjM915AUJ74J1X0vAp-7pHai8sBuqZLeiOKwdZjJJctlSm0qOx2_ieoPJ_oEyVdBrBk01ogYtQROEH7TjiSN5S9JcCsU4q-2vlHfSRazy3zT1Y-2bwd521Jsoq3Z48yprfU/s1600/nodes.png" width="400" /></a></div>
<br />
<br />
In what we want, the orientation is not directed and orthogonal lines are rendered the same way.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEk5-wVTU8N1-GATaDT6myDMUyH8ApRus8lAHFMpguKIit7XRjKM8lk3eYLPSxO00FHmjLwzKslzolaWlvhsumXFFeiQluMtlZiLtZx42-3MlWBjhIYgHZFERTCWkjJKxcXdpVHJv7YgI/s1600/segments.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEk5-wVTU8N1-GATaDT6myDMUyH8ApRus8lAHFMpguKIit7XRjKM8lk3eYLPSxO00FHmjLwzKslzolaWlvhsumXFFeiQluMtlZiLtZx42-3MlWBjhIYgHZFERTCWkjJKxcXdpVHJv7YgI/s1600/segments.png" width="194" /></a></div>
<br />
This way, all our segments cover just a quarter of a circle and their sine values range from 0 to 1.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZl4TSqlxLBwx9zGmU_js0eITcotPsSfBSHabNDRu9rfQirvJ6YTEZuiCpR5Kn0XDWyQdK_TxAulxWcJWDS-ZotqZwCZ90oAEmesOQnBqf46xP-TI4VyD6GdNv_SNuPyvETAQUgbtqPEw/s1600/cercle.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZl4TSqlxLBwx9zGmU_js0eITcotPsSfBSHabNDRu9rfQirvJ6YTEZuiCpR5Kn0XDWyQdK_TxAulxWcJWDS-ZotqZwCZ90oAEmesOQnBqf46xP-TI4VyD6GdNv_SNuPyvETAQUgbtqPEw/s1600/cercle.png" width="200" /></a></div>
We can affect each segment an angle. I classified my angle values in two classes, with punchy base colors.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpiUmYbjR8TrhC7Ov6FIUnqC6F3fJOf5ZdlHcsn1jtrmFFWxwZSdfjnnBkjAwfqkXeaRReetf7qzwtvPx5fVR110WnqRUYVwUbvA9Ns6n8r_zJuhLkimzOIG87oUnD3kayTo9fkfmz3N0/s1600/deux+couleurs.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="98" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpiUmYbjR8TrhC7Ov6FIUnqC6F3fJOf5ZdlHcsn1jtrmFFWxwZSdfjnnBkjAwfqkXeaRReetf7qzwtvPx5fVR110WnqRUYVwUbvA9Ns6n8r_zJuhLkimzOIG87oUnD3kayTo9fkfmz3N0/s1600/deux+couleurs.png" width="200" /></a></div>
<br />
Actually, values near 0 and 1 correspond to almost equivalent orientations. They correspond to angles near 0 / 90°. The difference of colors is maximal when two streets have a 45° difference of angles. I chose a kind of diverging palette with dark saturated colors near 45° and bright desaturated ones near 0 / 90°. This way, similar angles are given similar brightness values.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi30BjQo5eIB8IpZbqHC9go0iuivWsaLai35CmAViS9n4Dlqy6BhPRYfQDfBnm40GmhtQc1Ps1Y4iE1A5tjuEqv53eUVzSD0dWS_a3ph0elg7Yk4tuVZ2NNk3ouJh6B0RSNPODSG9o34fQ/s1600/gradient.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi30BjQo5eIB8IpZbqHC9go0iuivWsaLai35CmAViS9n4Dlqy6BhPRYfQDfBnm40GmhtQc1Ps1Y4iE1A5tjuEqv53eUVzSD0dWS_a3ph0elg7Yk4tuVZ2NNk3ouJh6B0RSNPODSG9o34fQ/s1600/gradient.png" width="200" /></a></div>
Here is the result for our roads :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0ukPFaLLKFK8G8mkShOPoQ_XcIEMHOuRN7GILlvD8b-HFo04aIByjCQd86hpBhZIgeS8ozaW9V9mel3TYgITCShoyzyQgfEF2N8tS5jd1T4ZwVnKLAfvb-0QRb9oXj1EuTctGkqb34gM/s1600/paris_v.jpeg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="452" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0ukPFaLLKFK8G8mkShOPoQ_XcIEMHOuRN7GILlvD8b-HFo04aIByjCQd86hpBhZIgeS8ozaW9V9mel3TYgITCShoyzyQgfEF2N8tS5jd1T4ZwVnKLAfvb-0QRb9oXj1EuTctGkqb34gM/s1600/paris_v.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Rendering with the inner orientation affected to the segments</td></tr>
</tbody></table>
<br />
The second part is mostly cosmetic. We'll use interpolation and smoothing to get a nice halo effect.<br />
<br />
First, we generate the mid point of each line and affect the orientation to it.<br />
<br />
Next, we process the interpolation by inverse distance weight based on these points and their orientation values.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyYkdibRczMG7yfilk6dV7nUYtEgfjZnA_v-szej-IxnTW_s5v1TwkzOlTEnMMJNHhciw2-GXB56U_RWIPEsaLL0_TaVJG1l3OEKw_itzXNeHYR3pXTaJXLhmnFwQ69MQ4an5ZHfhtfgM/s1600/interpolation.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="205" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyYkdibRczMG7yfilk6dV7nUYtEgfjZnA_v-szej-IxnTW_s5v1TwkzOlTEnMMJNHhciw2-GXB56U_RWIPEsaLL0_TaVJG1l3OEKw_itzXNeHYR3pXTaJXLhmnFwQ69MQ4an5ZHfhtfgM/s1600/interpolation.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">interpolation</td></tr>
</tbody></table>
<br />
Finally, we smooth the continuous surface to get something more pleasant.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2MKOvz2iXu9xWUGMbhVi13p_Yobkws59vreLKRtHHZWR9qSrXKT_WbIme5giScGKw_gL-jy3fbP2BsOZF9O_7KUILgadxHJ8pYwJ-9vBNfbx9flhstbnkRm0YRiOJi0YiJCfsu5_EOfg/s1600/Rplot.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2MKOvz2iXu9xWUGMbhVi13p_Yobkws59vreLKRtHHZWR9qSrXKT_WbIme5giScGKw_gL-jy3fbP2BsOZF9O_7KUILgadxHJ8pYwJ-9vBNfbx9flhstbnkRm0YRiOJi0YiJCfsu5_EOfg/s1600/Rplot.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Interpolated raster & the same, smoothed</td></tr>
</tbody></table>
<br />
<br />
We export the smoothed raster for a rendering within QGIS.<br />
<br />
Here is how I superimposed my layers :<br />
<ol>
<li>The <b>raster </b>is put on top with the palette described above and a specific "<i>Overlay</i>" blending mode.</li>
<li>The <b>roads </b>are put below with a grey value. Note that the grey value affects the final color because of the blending mode.</li>
<li>Finally, <b>a near black background</b> lets the halo appear slightly.</li>
</ol>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihHcqFdAX8MKh-bzUtwyM31WsQ_QsMgVNyZa1K2wv0XRIzmfsprXBRVl9O_SQNKg7_X2VdsA_kKAjXRK9isoteW3660J5MU9oc4oDOeyk8OMF0BO01GcPUQLvdRTy4VvJFbQHUGWXqkZ8/s1600/blending.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="184" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihHcqFdAX8MKh-bzUtwyM31WsQ_QsMgVNyZa1K2wv0XRIzmfsprXBRVl9O_SQNKg7_X2VdsA_kKAjXRK9isoteW3660J5MU9oc4oDOeyk8OMF0BO01GcPUQLvdRTy4VvJFbQHUGWXqkZ8/s1600/blending.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmHFKZtuFwwMGJDt4jLoH4zN0WJrBMNQw8YvvvjINyQlfoxWry85p0-P3-Opi-a1gJHJ-i080hGOWS3mdR6PkBDvSQ9WTW5Fyr8WD4ykqdRF8VEj7ueRbwUfljtHlahwibaK7x8KdXMV4/s1600/overlaying.jpeg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="420" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmHFKZtuFwwMGJDt4jLoH4zN0WJrBMNQw8YvvvjINyQlfoxWry85p0-P3-Opi-a1gJHJ-i080hGOWS3mdR6PkBDvSQ9WTW5Fyr8WD4ykqdRF8VEj7ueRbwUfljtHlahwibaK7x8KdXMV4/s1600/overlaying.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">How the underlying color affects the final rendering in an overlay blending mode</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Here is the result for Paris :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://www.flickr.com/photos/10519370@N04/15654896891/" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto; text-align: center;" target="_blank"><img border="0" height="428" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY29reF2tt0UKMWTQZkzHqJU4uU_u7F_GZri9mGdIZZibpB9agf8qUe4sfy6S62wrJhJxNWXca32bB0Gi_Pe9iFeUfCyQEyfeG2SD3jUCgBEKplRjvjkn7qqwzQy5_qkr2UBwMWWBkPHE/s1600/paris.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Smoothed result with a kind of halo (click to see in large scale)</td></tr>
</tbody></table>
<b><span style="color: orange;"><br /></span></b>
I decided to apply the process to a sample of NYC :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://www.flickr.com/photos/10519370@N04/15780248325/" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvX6O9DxA7W__cmpJ2gU0nrxkBRcSWZgVcuQqpn4App6aD7zexAxdW7wOhlhBuOvuEtfOSt6wOitd4wQLf9OvTNQyCMPiHSrco2OtvIEMkeFvYhe-RFaC63IcbzN7St1Re4C1U_QXwr1E/s640/nyc_new.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">NYC Streets oriented (click to see in large scale)</td></tr>
</tbody></table>
<b><span style="color: orange;"><br /></span></b>
<b><span style="color: orange;">Technical details and code</span></b><br />
<b><span style="color: #b45f06;"><br /></span></b>
The two key functions are :<br />
<i>spatstat::angles.psp</i> which compute the angles of segments<br />
<i>spatstat::idw</i> which interpolates the data.<br />
<br />
<script src="https://gist.github.com/datagistips/e0b6ec8c7100e9b92b65.js"></script>harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com7tag:blogger.com,1999:blog-9055497882207462476.post-1372227911301611882014-06-07T00:04:00.000-07:002014-11-18T00:29:30.063-08:00whatGoogleSuggestsFor() : Using Google Instant to map Stereotypes or Sentiment (in R)<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpKCsh_n8l_KVUO76Z0Dyh00kDIMtX1MSraUfp5ld7LEjbAwld6CZXRYr-9lYuCpdIPPTp0FsL4ct3NVDaDnqMasDGLnQBteQAeJ4g7MYw9dna8iOn1tYyFoukgyt3nxctBXL5eoVKl2M/s1600/why.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpKCsh_n8l_KVUO76Z0Dyh00kDIMtX1MSraUfp5ld7LEjbAwld6CZXRYr-9lYuCpdIPPTp0FsL4ct3NVDaDnqMasDGLnQBteQAeJ4g7MYw9dna8iOn1tYyFoukgyt3nxctBXL5eoVKl2M/s1600/why.png" height="108" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Some interesting things emerge <a href="http://noahveltman.com/suggest/" target="_blank">when using Google Instant service from different countries</a>.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6qrSirBd_vjI9af3l5rfYhyphenhyphen0TdhyphenhyphenZScbPHkIqSdR05NT6fPCHRTea8YJcPj1xWyhyphenhyphenHPTll5249edhJ2SZdil7QlWXC4d397ecB_ghlnmEEqN8tyM8Hu4D8MVMl8HIerQKYwaTx0kwkX8/s1600/world.jpeg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6qrSirBd_vjI9af3l5rfYhyphenhyphen0TdhyphenhyphenZScbPHkIqSdR05NT6fPCHRTea8YJcPj1xWyhyphenhyphenHPTll5249edhJ2SZdil7QlWXC4d397ecB_ghlnmEEqN8tyM8Hu4D8MVMl8HIerQKYwaTx0kwkX8/s1600/world.jpeg" height="123" width="200" /></a>The <span style="font-family: Courier New, Courier, monospace;">whatGoogleSuggestsFor()</span> function will take a string as an input and return a list of suggestions by Google based upon Google Instant Service. Good to map stereotypes or analyze sentiment of a brand. The code is at the end.<br />
<br />
<u><br /></u>
<u><br /></u><br />
<a name='more'></a><u><br /></u>
<u>For instance, we could get stereotypes attributed to <b>France</b>, seen from the US</u><br />
<br />
<span style="color: #b45f06; font-family: Courier New, Courier, monospace;">> whatGoogleSuggestsFor("why france", domain="us")</span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> " is great" " joined ww1" " banned the burqa" </span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;">" gave statue of liberty" " is better than germany" " colonized algeria" </span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> " sold louisiana" " banned fracking" "sa left yes" </span><br />
<br />
<u><br /></u>
<u>Or, a global advice on <b>Nike </b>Company</u><br />
<span style="color: #b45f06; font-family: 'Courier New', Courier, monospace;">> whatGoogleSuggestsFor("why nike is", domain="us")</span><span style="font-family: 'Courier New', Courier, monospace;"></span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> " bad" " better than adidas" " the best" </span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> " successful" " a good investment" " the best sports brand" </span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> " popular" " better" " the best brand" </span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> " so popular" </span><br />
<br />
<u><br /></u>
<u>Some concerns about the the World Cup when you question the future of <b>Brazil</b></u><br />
<br />
<span style="color: #b45f06; font-family: Courier New, Courier, monospace;">> whatGoogleSuggestsFor("will Brazil", domain="us")</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"> " win the world cup" " be ready for the world cup" " be ready for the olympics" </span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> " be ready" " be ready for the 2016 olympics" " be ready for 2014 world cup" </span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> " be a superpower" " lose olympics" " be safe for the world cup" </span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;">" be ready to host the world cup" </span><br />
<br />
<u><br /></u>
<u>You could use that function in a script to collect suggestions for <b>a list of questions</b>.</u><br />
<br />
<span style="font-family: Courier New, Courier, monospace;"> prefix suggestion</span><br />
<span style="font-family: Courier New, Courier, monospace;">1 why europe is better than america</span><br />
<span style="font-family: Courier New, Courier, monospace;">2 why europe is a continent</span><br />
<span style="font-family: Courier New, Courier, monospace;">3 why europe is awesome</span><br />
<span style="font-family: Courier New, Courier, monospace;">4 why europe is called europe</span><br />
<span style="font-family: Courier New, Courier, monospace;">5 why europe is not a continent</span><br />
<span style="font-family: Courier New, Courier, monospace;">6 why europe is so expensive</span><br />
<span style="font-family: Courier New, Courier, monospace;">7 why europe is the best place to visit</span><br />
<span style="font-family: Courier New, Courier, monospace;">8 why europe is considered as a continent</span><br />
<span style="font-family: Courier New, Courier, monospace;">9 why europe is rich</span><br />
<span style="font-family: Courier New, Courier, monospace;">10 why europe is better than australia</span><br />
<span style="font-family: Courier New, Courier, monospace;">11 why africa is poor</span><br />
<span style="font-family: Courier New, Courier, monospace;">12 why africa is underdeveloped</span><br />
<span style="font-family: Courier New, Courier, monospace;">13 why africa is not developing</span><br />
<span style="font-family: Courier New, Courier, monospace;">14 why africa is called dark continent</span><br />
<span style="font-family: Courier New, Courier, monospace;">15 why africa is still starving</span><br />
<span style="font-family: Courier New, Courier, monospace;">16 why africa is the most homophobic continent</span><br />
<span style="font-family: Courier New, Courier, monospace;">17 why africa is still poor</span><br />
<span style="font-family: Courier New, Courier, monospace;">18 why africa is poor greg mills</span><br />
<span style="font-family: Courier New, Courier, monospace;">19 why africa is behind</span><br />
<span style="font-family: Courier New, Courier, monospace;">20 why africa is not a dark continent</span><br />
<span style="font-family: Courier New, Courier, monospace;">21 why asia is better than america</span><br />
<span style="font-family: Courier New, Courier, monospace;">22 why asia is better than africa</span><br />
<span style="font-family: Courier New, Courier, monospace;">23 why asia is better than europe</span><br />
<span style="font-family: Courier New, Courier, monospace;">24 why asia is called asia</span><br />
<span style="font-family: Courier New, Courier, monospace;">25 why asia is important</span><br />
<span style="font-family: Courier New, Courier, monospace;">26 why asia is poor</span><br />
<span style="font-family: Courier New, Courier, monospace;">27 why asia is so populated</span><br />
<span style="font-family: Courier New, Courier, monospace;">28 why asia is called continent of contrasts</span><br />
<span style="font-family: Courier New, Courier, monospace;">29 why asia is densely populated</span><br />
<span style="font-family: Courier New, Courier, monospace;">30 why asia is called land of extremes</span><br />
<br />
So then, you can map stereotypes all over the world.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6qrSirBd_vjI9af3l5rfYhyphenhyphen0TdhyphenhyphenZScbPHkIqSdR05NT6fPCHRTea8YJcPj1xWyhyphenhyphenHPTll5249edhJ2SZdil7QlWXC4d397ecB_ghlnmEEqN8tyM8Hu4D8MVMl8HIerQKYwaTx0kwkX8/s1600/world.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6qrSirBd_vjI9af3l5rfYhyphenhyphen0TdhyphenhyphenZScbPHkIqSdR05NT6fPCHRTea8YJcPj1xWyhyphenhyphenHPTll5249edhJ2SZdil7QlWXC4d397ecB_ghlnmEEqN8tyM8Hu4D8MVMl8HIerQKYwaTx0kwkX8/s1600/world.jpeg" height="394" width="640" /></a></div>
<br />
<br />
<script src="https://gist.github.com/datagistips/0516ab5410174e15e79f.js"></script>harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-60483643787286634982013-11-24T09:08:00.000-08:002013-12-02T01:19:53.192-08:00QGIS 2 : Artificialisation du sol en Île de France // Les modes de rendu par fusion<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKNOSY9mtqgkZrHooHXh5jTSyux02emsMDXroz_BM3fka_EhshFbFY06va1NXgicnmeJe58UwBVzxgxq7_maXGyMxyM8PdZhfSAflg3a9FyiQmMy_uEMmV6e5eQdNc9bQfu8kVUU6PVg8/s1600/carte.jpeg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKNOSY9mtqgkZrHooHXh5jTSyux02emsMDXroz_BM3fka_EhshFbFY06va1NXgicnmeJe58UwBVzxgxq7_maXGyMxyM8PdZhfSAflg3a9FyiQmMy_uEMmV6e5eQdNc9bQfu8kVUU6PVg8/s200/carte.jpeg" width="200" /></a>Dans cet article, nous allons voir comment tirer parti des modes de rendu révolutionnaires de la version QGIS 2 pour représenter le phénomène d'artificialisation en Île-de-France de 1990 à 2006.</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<a name='more'></a><br />
<div class="separator" style="clear: both; text-align: left;">
Selon Wikipédia, <i>"on parle d’<a href="http://fr.wikipedia.org/wiki/Artificialisation">artificialisation</a> du sol ou d'un milieu, d'un habitat naturel ou semi-naturel quand ces derniers perdent les qualités qui sont celles d'un milieu naturel"</i>.</div>
<br />
L'artificialisation se produit le plus souvent lors de la construction de bâ<span style="text-align: center;">timents, d'infrastructures de transport. Elle amène l'imperméabilisation des milieux et est d'autant plus dramatique lorsqu'elle concerne des terres à bon potentiel agronomique ou des réservoirs de biodiversité . Son effet est quasi-irréversible.</span><br />
<span style="text-align: center;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmq9eIlPJyCAfsk2QnpDJQLBQi1Dka3MJZ8C8-g19Hgd6SrAn24iSZUXctnj1exTMVOzjemkwmtX3184TiDMI_QiUFPx9rlz16jQGPQrJDubRDLOM7auEzaftq08HPOHJg1JSehQ485Pw/s1600/pas+bon.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="263" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmq9eIlPJyCAfsk2QnpDJQLBQi1Dka3MJZ8C8-g19Hgd6SrAn24iSZUXctnj1exTMVOzjemkwmtX3184TiDMI_QiUFPx9rlz16jQGPQrJDubRDLOM7auEzaftq08HPOHJg1JSehQ485Pw/s400/pas+bon.png" width="400" /></a></div>
<br />
<br />
Il serait intéressant de voir comment le phénomène d'artificialisation a évolué sur une dizaine d'années, par exemple sur le territoire d'Île-de-France.<br />
<br />
Voici la carte que nous allons réaliser ensemble :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://plus.google.com/photos/111811930743516351726/albums/5319848957628237553/5951581488305513826?banner=pwa&authkey=CJj_tM76x5Dufw&pid=5951581488305513826&oid=111811930743516351726" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" height="452" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKNOSY9mtqgkZrHooHXh5jTSyux02emsMDXroz_BM3fka_EhshFbFY06va1NXgicnmeJe58UwBVzxgxq7_maXGyMxyM8PdZhfSAflg3a9FyiQmMy_uEMmV6e5eQdNc9bQfu8kVUU6PVg8/s640/carte.jpeg" width="640" /></a></div>
<br />
Pour cela, nous récupérons les données Corine Land Cover d'occupation du sol des années 1990 et 2006 <a href="http://www.statistiques.developpement-durable.gouv.fr/donnees-ligne/t/telechargement-donnees.html?tx_ttnews%5Btt_news%5D=11263&cHash=198a579c8e605a1c967fabbd0cbc48a2">sur le site du SOeS </a>(Service d'Observation & de Statistiques).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv70O0DdP2t5YPWU7Z4-WHCWyw57ND-kghRftHqGvzNUsCPUFyvbd-fVyT51O0dTuQpk0nuPB7N9Bh7DsCk7TU7VB52NHJ2pOBiYHnhlRLKnCIkOO9YhekuxCSwUV_aI2AkWADc3UGQIU/s320/clc.PNG" width="320" /><span id="goog_1387325605"></span><span id="goog_1387325606"></span><a href="http://www.blogger.com/"></a></div>
<br />
<br />
Voici à quoi ressemble la donnée une fois mise en forme :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9MtsGyI9bn57kuDWkhmw0DdfRLzIpf2163hC403J8sVc2_4r35jV1sxRT90e3Phyd-n3Cq0Aqf9o_3F8frFXP9tUeaaIuAwStM80tr7o4sLjQydUEYKK-JfAj_eRcacru_SWb1upTVbM/s1600/clc06.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="422" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9MtsGyI9bn57kuDWkhmw0DdfRLzIpf2163hC403J8sVc2_4r35jV1sxRT90e3Phyd-n3Cq0Aqf9o_3F8frFXP9tUeaaIuAwStM80tr7o4sLjQydUEYKK-JfAj_eRcacru_SWb1upTVbM/s640/clc06.jpeg" width="640" /></a></div>
<br />
Chargeons les données dans notre base Postgre/PostGIS via l'outil <i>DBManager</i> (disponible dans le menu Base de données). Les performances de Postgre/PostGIS seront nécessaires pour réaliser les traitements spatiaux dont nous aurons besoin.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEQCHJqEDIMXpk7vxwDw41gt4L6-86oMbBs4SspvCJHmrQi1GOZq3JytOCGmPWxNjyIo2wK7eEitiFs-80ycIJA0Rg2ubJLz_OArVBI3Kwyuo9tVLWVmrehh462OBo7zPzl0mVGwvS6ws/s1600/chargement.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEQCHJqEDIMXpk7vxwDw41gt4L6-86oMbBs4SspvCJHmrQi1GOZq3JytOCGmPWxNjyIo2wK7eEitiFs-80ycIJA0Rg2ubJLz_OArVBI3Kwyuo9tVLWVmrehh462OBo7zPzl0mVGwvS6ws/s400/chargement.PNG" width="330" /></a></div>
<br />
<br />
Nous souhaitons avoir en sortie une couche représentant les zones ayant fait l'objet d'artificialisation sur la région. Le code correspondant aux espaces artificialisés est 1 selon CLC.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzhAYVrvDGYpjxHRB3J1_LZfYlnvRKpUG6_Dydv9_Nh9KMGhoq8z2aDDqW4gpfdNyiNYUr2gdLLkWOGK0G4Bkw1KfrdwDzw4hulUZRltgFsbPIeYQLL9xA4T_5uIDz80QoatXt6WRnbcY/s1600/clc+cat.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzhAYVrvDGYpjxHRB3J1_LZfYlnvRKpUG6_Dydv9_Nh9KMGhoq8z2aDDqW4gpfdNyiNYUr2gdLLkWOGK0G4Bkw1KfrdwDzw4hulUZRltgFsbPIeYQLL9xA4T_5uIDz80QoatXt6WRnbcY/s400/clc+cat.PNG" width="300" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Les zones artificialisées correspondront aux parties de la couche CLC 1990 dont le code n'était pas 1 qui sont passées au code 1 dans la couche 2006. Il s'agit donc des objets résultant de l'intersection entre les deux couches.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj40Ve4AYDRhDTP_z58gpuT1ySO4aHNaBGMLShYwiyexY8wErpYaNlvsm6bmV6I8VOXZr3y6zNCW9gjQdhZJ-VJUHejA3l72GHVRgtEwYRreEdX9eTY4TaIACWLbvlAxEI9EozDxOxH-BE/s1600/intersection.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="201" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj40Ve4AYDRhDTP_z58gpuT1ySO4aHNaBGMLShYwiyexY8wErpYaNlvsm6bmV6I8VOXZr3y6zNCW9gjQdhZJ-VJUHejA3l72GHVRgtEwYRreEdX9eTY4TaIACWLbvlAxEI9EozDxOxH-BE/s320/intersection.png" width="320" /></a></div>
<br />
Exécutons la requête SQL via DBManager afin de créer la couche. On génère une couche de centroïdes car nous lui appliquerons un rendu en symboles proportionnels à la surface ayant été impactée par le changement d'occupation.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXeoQ80IakFRY23ClHLhiSQJE_YTaWGLrSlY08JZvWBfXEsAaWvnAS1nRZVBV_BEd8hsuQLjJ52a68eU1F_JTYDzKuMNGrK-I-tybDtdVzWdyPOdUfhiblO-Ymc-W4j3TLWJP3zCNREW4/s1600/requete.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="470" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXeoQ80IakFRY23ClHLhiSQJE_YTaWGLrSlY08JZvWBfXEsAaWvnAS1nRZVBV_BEd8hsuQLjJ52a68eU1F_JTYDzKuMNGrK-I-tybDtdVzWdyPOdUfhiblO-Ymc-W4j3TLWJP3zCNREW4/s640/requete.PNG" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fenêtre SQL de DBManager</td></tr>
</tbody></table>
<br />
Une fois la requête exécutée, la couche <i>evol_idf_90_06</i> est créée et disponible dans le contrôle des couches.<br />
<br />
Voici les changements que l'on observe en superposant la couche d'évolution sur, respectivement la couche CLC 1990 et CLC 2006 :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqyavoqzGrPTOSePevQUYtM2wdjF5UdomrZIXWYa3Nv99enrkf43yQky4O4D2LfDOMLWmNfr1zxoYNODQzS9J8d-G0OEyr_jg54RC9pYHmKvYamo3zwbFjfdWI0lIFfEUwzrvqbUGYozI/s1600/evolclc.jpeg" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="452" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqyavoqzGrPTOSePevQUYtM2wdjF5UdomrZIXWYa3Nv99enrkf43yQky4O4D2LfDOMLWmNfr1zxoYNODQzS9J8d-G0OEyr_jg54RC9pYHmKvYamo3zwbFjfdWI0lIFfEUwzrvqbUGYozI/s640/evolclc.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Tiens, on a construit une route dans cette zone. L'urbanisation a sans doute suivi !</td></tr>
</tbody></table>
<br />
Créons un nouveau champ dans cette couche où stocker le premier niveau de CLC année 90 :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-Yn5NLeCMjnZe0Pm40b_c9Xk8WcqsRav2qW5kGdb8-UVlehiG2yaTVit87koDHSzzKCnCj2QGzLdaJKmelSfokZCZOwYznzKuto_QE7eOo_dSr0sohwG3AIEsAAGRtZI3-1fu-w16i14/s1600/nouveau+champ+code+un.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="382" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-Yn5NLeCMjnZe0Pm40b_c9Xk8WcqsRav2qW5kGdb8-UVlehiG2yaTVit87koDHSzzKCnCj2QGzLdaJKmelSfokZCZOwYznzKuto_QE7eOo_dSr0sohwG3AIEsAAGRtZI3-1fu-w16i14/s400/nouveau+champ+code+un.PNG" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Création d'un champ stockant le premier niveau/poste de CLC</td></tr>
</tbody></table>
<br />
<br />
C'est sur ce champ-là, codeUn, que nous réaliserons le rendu catégorisé.<br />
<br />
Comme couleurs, j'ai choisi du <span style="color: #783f04;"><b>marron</b></span> pour les terres agricoles, du <b><span style="color: #6aa84f;">vert </span></b>pour les forêts et milieux semi-naturels, du <span style="color: #3d85c6;"><b>bleu</b></span> pour les zones humides et les surfaces en eau.<br />
<br />
Utilisons les options de taille de symbole en utilisant la surface comme paramètre<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd4pZ6QvCD4LhWPeEb-45F8cCyQsG2S-1dliRQdgkXPVq_Qr49YcyL3RRl-xiSuRiMNNQaQCjny-WoYfeMNXZ77hDlrbpXg4AB1GJnMyNRuq_6EH6Iz5IqdNWboAgnzqr5vCIEXpgihZY/s1600/proportion.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd4pZ6QvCD4LhWPeEb-45F8cCyQsG2S-1dliRQdgkXPVq_Qr49YcyL3RRl-xiSuRiMNNQaQCjny-WoYfeMNXZ77hDlrbpXg4AB1GJnMyNRuq_6EH6Iz5IqdNWboAgnzqr5vCIEXpgihZY/s1600/proportion.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Symboles proportionnels</td></tr>
</tbody></table>
<br />
Entrons maintenant dans le coeur du sujet. Avant, en opensource, seul <a href="http://mapnik.org/">Mapnik</a> permettait de réaliser des opérations de fusion entre couches comparables à ce que l'on pouvait trouver avec les calques en PAO comme Gimp.<br />
<br />
Pour le mode de rendu entre objets, nous utilisons le mode <i>addition</i>. Le mode <i>addition </i>appliqué aux objets permet de faire s'ajouter les valeurs des pixels si bien que là où des objets se superposent, on tend vers la couleur blanche, les valeurs R G B du blanc étant maximales (255 255 255). Au final, la carte semble s'allumer là où il y a beaucoup d'objets, soit là où il y a beaucoup d'artificialisation.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioCI6gfVxXmKh_zLncFqBTcvFx0FoBEbdW65mjpBLy5OCxNHLmTGQ4oEqFFZNFycKCzEA5eFvbVE-04MBOI36tiod8Abq0Q24UEBCUm_nzZ6azr4kC11tuwbpL0mS_gQ9rC3Ddy8znhMU/s1600/fusion+rendu.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="98" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioCI6gfVxXmKh_zLncFqBTcvFx0FoBEbdW65mjpBLy5OCxNHLmTGQ4oEqFFZNFycKCzEA5eFvbVE-04MBOI36tiod8Abq0Q24UEBCUm_nzZ6azr4kC11tuwbpL0mS_gQ9rC3Ddy8znhMU/s640/fusion+rendu.PNG" width="640" /></a><br />
<br />
Si l'on avait choisi un mode de rendu normal, nous n'aurions pas perçu le phénomène de la même façon :<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDbHiL266oSXYVwjlaFLXJMLRj8dBYFftwV5hAfJaox3FgCnaKFBQT1zQE7jWx4kRAl-axGfKyvvI2QJi0BGCGxcZaIDx_xgq4Ltud8a4NZ-LnNV4x_qYTiFNnEH5YUjjNP-DzbET31mQ/s1600/normal.jpeg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDbHiL266oSXYVwjlaFLXJMLRj8dBYFftwV5hAfJaox3FgCnaKFBQT1zQE7jWx4kRAl-axGfKyvvI2QJi0BGCGxcZaIDx_xgq4Ltud8a4NZ-LnNV4x_qYTiFNnEH5YUjjNP-DzbET31mQ/s640/normal.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Mode de fusion par objets "normal" vs mode "addition"</td></tr>
</tbody></table>
<br />
Pour le rendu de la couche par rapport à celles qui se situent en-dessous, j'ai choisi le mode <i>Lumière Douce</i>.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWaNPT7QtY85UMDMp0xS8cMgAYptir3iOaTfnhQDKdEfjGD2X6dXA_y-tENDEGEUN_Zm2ysjDkL60yES9-A03x38IR-wzdFzfmpYc79VQbjGANl6mGWej050C6ERrBhxhjsnYLIqu3Nwg/s1600/soft+light.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWaNPT7QtY85UMDMp0xS8cMgAYptir3iOaTfnhQDKdEfjGD2X6dXA_y-tENDEGEUN_Zm2ysjDkL60yES9-A03x38IR-wzdFzfmpYc79VQbjGANl6mGWej050C6ERrBhxhjsnYLIqu3Nwg/s1600/soft+light.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Mode 'Soft Light' tel<br />
qu'illustré par l'outil Imagemagick</td></tr>
</tbody></table>
Le mode "<i>Lumière douce</i>" permet de rendre la couche plus brillante, vive et contrastée.<br />
<br />
Pour la couche de base, j'ai utilisé la couche Corine Land Cover la plus récente en choisissant des teintes en niveau de gris, et non en couleur afin d'éviter les conflits avec les couleurs de la couche d'évolution. J'ai tenté de retranscrire les couleurs initiales de la charte graphique en niveaux de gris. Les zones artificialisées ressortent en foncé, les zones de terres agricoles en clair et les forêts en un peu plus foncé.<br />
<br />
Pour les routes récupérées depuis <a href="http://professionnels.ign.fr/route500">la base Route500 ® récemment libérée par l'IGN</a>, j'ai choisi une couleur jaune pâle afin de mimer la lumière des lampes et donner un aspect électrique à la carte. Le problème est que là où la carte s'"allume", les routes ne sont plus discernables car se fondant avec le blanc. Le mode <i>Différencier</i> permet d'inverser la couleur des routes sur ces zones, ce qui les rend discernables.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib8i-PoLDq839SqgcT9uW9cYKC0fyJV9sLxiDpJJr9RXSyd23Uwh-V12_fGPKlQ_vsbqTOcW5A_jPz-8srPVgvKFosGH3HaCFnJJJ1etbunMkQO92LvhLCFtspqNZ4mewv5qcQ3GMGrlA/s1600/differncier.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib8i-PoLDq839SqgcT9uW9cYKC0fyJV9sLxiDpJJr9RXSyd23Uwh-V12_fGPKlQ_vsbqTOcW5A_jPz-8srPVgvKFosGH3HaCFnJJJ1etbunMkQO92LvhLCFtspqNZ4mewv5qcQ3GMGrlA/s1600/differncier.PNG" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Mode 'Différencier' tel <br />
qu'illustré par l'outil Imagemagick</td></tr>
</tbody></table>
On voit selon ce graphique que là où le clair de la source rejoint le clair de la destination, on obtient une couleur sombre.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMDmV2kZQA8O14dG-5kc2x9Ldh0G9pXhsIyh-iMES8xsFshaVqsnF_ArXxH5k5uiGfxiUrEMfn54YoTW5_XAZXvWByN9B8dE5NqtsP5br7dzCLXrtEprPVJ-1IFC5Hk3lF2-2-b9g3m4Y/s1600/diff%C3%A9rencier.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMDmV2kZQA8O14dG-5kc2x9Ldh0G9pXhsIyh-iMES8xsFshaVqsnF_ArXxH5k5uiGfxiUrEMfn54YoTW5_XAZXvWByN9B8dE5NqtsP5br7dzCLXrtEprPVJ-1IFC5Hk3lF2-2-b9g3m4Y/s320/diff%C3%A9rencier.PNG" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Mode de rendu différencié sur une zone</td></tr>
</tbody></table>
<br />
<br />
Les étiquettes correspondent aux catégories 1 à 4 des communes du <a href="http://professionnels.ign.fr/rgc">RGC ® de l'IGN</a> (Répertoire Géographique des Communes), lui aussi diffusé par l'IGN.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2ao0DUSYcKL10gSYY8z2CbHWjnKc8KaRhwkkxXOKYciiPhYOM39zll0lnGNiIciJf8_IIH7z-9AfGvgBVgbb2x-nJBBt6xTlMgX3fhfqBU5zRH4JquX-u6cWtMOyUPWVtcZHIX7fIPxk/s1600/rgc.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2ao0DUSYcKL10gSYY8z2CbHWjnKc8KaRhwkkxXOKYciiPhYOM39zll0lnGNiIciJf8_IIH7z-9AfGvgBVgbb2x-nJBBt6xTlMgX3fhfqBU5zRH4JquX-u6cWtMOyUPWVtcZHIX7fIPxk/s400/rgc.PNG" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ2KhI6WV3-D4VtYfSwbo9OBWBQTI-JN-dvmNezs5uwULINTSAt4fJHRzsh1TSb9mzD7DF6Zn8himOMNaCV2wNSSVpSACv0TCPbNFhEY-k1SVz-qqOafp2cacSbKdyWKcLZBpG4HNyGh8/s1600/admi.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ2KhI6WV3-D4VtYfSwbo9OBWBQTI-JN-dvmNezs5uwULINTSAt4fJHRzsh1TSb9mzD7DF6Zn8himOMNaCV2wNSSVpSACv0TCPbNFhEY-k1SVz-qqOafp2cacSbKdyWKcLZBpG4HNyGh8/s1600/admi.PNG" /></a></div>
<br />
<br />
Nous appliquons une formule permettant d'avoir les noms en minuscules, car les minuscules occupent moins de place sur la carte. Seule la première lettre du nom reste en majuscule. Nous projetons des ombres sur les étiquettes pour un rendu futuriste avec un décalage de 0 mm pour l'effet de halo.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQLs-mQBBiD1mDHINb-_roj94q-bKR-LNtT50IzWnyfSEN2-BBpjxNZOaYmZv72NJ3-89w7kGImJhxMWD5Xy3aWBt5rF_Y7XtPFHp4gMDUNybkk704cr3hmRGkrxrdDga7YejA0t0DAw0/s1600/ombres.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="428" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQLs-mQBBiD1mDHINb-_roj94q-bKR-LNtT50IzWnyfSEN2-BBpjxNZOaYmZv72NJ3-89w7kGImJhxMWD5Xy3aWBt5rF_Y7XtPFHp4gMDUNybkk704cr3hmRGkrxrdDga7YejA0t0DAw0/s640/ombres.PNG" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Paramétrage des étiquettes</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZHw8qXb6o_M8q_uzUpO-025QUyaWPf5oU9pGHWW1ssFXLDQgkynvJws4yZ-EN7SGL4FWUNxceZ_b54bDluab-wTz3Ez9zuivp3vg82TWs3rin1OQZlByZmHy6maJ0S2jcyW5HNjXLBbY/s1600/labels.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="197" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZHw8qXb6o_M8q_uzUpO-025QUyaWPf5oU9pGHWW1ssFXLDQgkynvJws4yZ-EN7SGL4FWUNxceZ_b54bDluab-wTz3Ez9zuivp3vg82TWs3rin1OQZlByZmHy6maJ0S2jcyW5HNjXLBbY/s400/labels.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Rendu avec tampon associé à un halo (ombre projetée)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Mettez un titre, une carte d'aperçu, une légende, une barre d'échelle, la fléche Nord, les sources et votre carte est finie !</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFRlyAyOmts5tG5WJ4F_K6-wCn0vTcRFq5DM-DJiF7_54MCYHzNUGQFZXq1Oa0SkEMJtZWhaBG4qKdvyUyrsKM4BHrZbZc2rVGH77AHS66OeOYHRLscLvNtwjbArGNrAZN4uV1-IT1Q8/s1600/annexes.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="114" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPFRlyAyOmts5tG5WJ4F_K6-wCn0vTcRFq5DM-DJiF7_54MCYHzNUGQFZXq1Oa0SkEMJtZWhaBG4qKdvyUyrsKM4BHrZbZc2rVGH77AHS66OeOYHRLscLvNtwjbArGNrAZN4uV1-IT1Q8/s640/annexes.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Les éléments complémentaires d'une carte politiquement correcte</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com4tag:blogger.com,1999:blog-9055497882207462476.post-30365694832019243912013-10-28T01:07:00.005-07:002013-10-28T01:10:17.931-07:00a QGIS tip : find mid-points of lines with no coding, only plugins<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie1nRRhK908HLw9nKQm_DJBwUK3CFSb97oJ1ADr620hRDZjmVLWpSbB6NfrYbQpEtcIGUYvj-2TGjckuV-9k8lKhkJtXg12qRAM9Bi6-lL4AgOsOv_t98Y0i4AfacouoLooG8VcCDJjck/s1600/interro.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie1nRRhK908HLw9nKQm_DJBwUK3CFSb97oJ1ADr620hRDZjmVLWpSbB6NfrYbQpEtcIGUYvj-2TGjckuV-9k8lKhkJtXg12qRAM9Bi6-lL4AgOsOv_t98Y0i4AfacouoLooG8VcCDJjck/s1600/interro.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="115" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie1nRRhK908HLw9nKQm_DJBwUK3CFSb97oJ1ADr620hRDZjmVLWpSbB6NfrYbQpEtcIGUYvj-2TGjckuV-9k8lKhkJtXg12qRAM9Bi6-lL4AgOsOv_t98Y0i4AfacouoLooG8VcCDJjck/s200/interro.jpg" width="200" /></a>Recently, a colleague of mine asked me if it was possible to generate mid-points for lines. The problem was that he had barrage data represented as lines and he wanted to see them on a map. So, getting the mid-point for these lines was a way to get the barrage location and put a symbol to each of it..</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<a name='more'></a><br />
<div>
I searched the net and fell upon <a href="http://gis.stackexchange.com/questions/58079/how-to-find-the-middle-point-of-a-line-in-qgis">a gis stackexhange</a> that mentionned a programming routine under python console</div>
<div>
Also, <a href="http://www.portailsig.org/content/pyqgis-des-geometries-des-vecteurs-de-l-algebre-vectorielle-ou-des-cosinus-directeurs-exempl">an article by Martin laloux</a>, a belgium GIS specialist could have been helpful to manage that.</div>
<div>
<br /></div>
<div>
These solutions could have been implemented under the form of a sextante toolbox function, or a plugin. But what if, like my colleague, you don't know how to code ? It's possible to generate mid-points from lines using QGIS plugins. Just follow the steps :</div>
<div>
<br /></div>
<div>
- Create a set of polylines</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinMGi0abuyx4eCGkCvwQ4U4BAr9_5uQ-Bxm_0TeaitzzeaLlYCzDWbDe7nrdyxIFQDwN4cREB0HvloOUwwAHRxCOFjqLVKV8sT_22Dq97Zxg5rhrfrVXIKsehVGNJ39F3YTIdJrrdvHDA/s1600/set.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="380" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinMGi0abuyx4eCGkCvwQ4U4BAr9_5uQ-Bxm_0TeaitzzeaLlYCzDWbDe7nrdyxIFQDwN4cREB0HvloOUwwAHRxCOFjqLVKV8sT_22Dq97Zxg5rhrfrVXIKsehVGNJ39F3YTIdJrrdvHDA/s640/set.PNG" width="640" /></a></div>
<div>
</div>
<div>
<br /></div>
<div>
- Separate the lines from the polylines with the sextante QGIS algorithm "explode lines"</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh67q5qVp1n7m0InVubHsBGUP6Jj0SPJZExWd9gqqrQTpBM0Ni0qbfXKtq9ocYCp7TretsD8KVebNuMTiJAeZJ3fatbUxe5Tr2Ph30Cq4Q_ubzO4Zc7lqC7yigzhYS9GxBctnFTEJkWWOI/s1600/explode.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh67q5qVp1n7m0InVubHsBGUP6Jj0SPJZExWd9gqqrQTpBM0Ni0qbfXKtq9ocYCp7TretsD8KVebNuMTiJAeZJ3fatbUxe5Tr2Ph30Cq4Q_ubzO4Zc7lqC7yigzhYS9GxBctnFTEJkWWOI/s400/explode.PNG" width="310" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
Add a unique identifier for every line with the calculator :</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjudaZSVsvztfOVoSo0HUuOpp_b2tZh-gwlEmOdafjcJDYUuoMvKglslPfKc_f8d3uYq4dLSV7o_nHDL3v7Twqdi4yD4fZQF8uxjfkTfHCZNQoNzf1l4vY0xUyN7tpCLg5L_iD6v7XigTc/s1600/rownum.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="608" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjudaZSVsvztfOVoSo0HUuOpp_b2tZh-gwlEmOdafjcJDYUuoMvKglslPfKc_f8d3uYq4dLSV7o_nHDL3v7Twqdi4yD4fZQF8uxjfkTfHCZNQoNzf1l4vY0xUyN7tpCLg5L_iD6v7XigTc/s640/rownum.PNG" width="640" /></a></div>
<div>
<br /></div>
<div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhDfOLmgtu0QDF7oaH5B72185eCrsIVeTy8N8nI2CUKo7pcbGzvvLmMlEY-FpU2GRHHjbmV3kBeKSPbmrLE9xqxVqSlONxsx3sqEO7HfgRD4oy5IzrAl5grXMiPfqhGfZVNL3fu2Vt1Vo/s1600/exploded.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="388" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhDfOLmgtu0QDF7oaH5B72185eCrsIVeTy8N8nI2CUKo7pcbGzvvLmMlEY-FpU2GRHHjbmV3kBeKSPbmrLE9xqxVqSlONxsx3sqEO7HfgRD4oy5IzrAl5grXMiPfqhGfZVNL3fu2Vt1Vo/s640/exploded.PNG" width="640" /></a></div>
<div>
<br /></div>
<div>
Extract the nodes</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8JMEnz9OnXH71jk3simlN-FmuBJ8Fe_C4YPHY_boymGKOfMaQs708R4Pdbng_4W5_pI8fyklzfhnlJyEZ2XyMIY1JAZj-2jDfIKGSH6BZl1U67rYehwgJkgkqdGO7ejQFTv6bYtLqUG8/s1600/points.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="382" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8JMEnz9OnXH71jk3simlN-FmuBJ8Fe_C4YPHY_boymGKOfMaQs708R4Pdbng_4W5_pI8fyklzfhnlJyEZ2XyMIY1JAZj-2jDfIKGSH6BZl1U67rYehwgJkgkqdGO7ejQFTv6bYtLqUG8/s640/points.PNG" width="640" /></a></div>
<div>
</div>
<div>
<br /></div>
<div>
Add the geometry columns</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP5YlLOHSYpchokSB4LCpuzQx2rXESPmltIiz1iL7yBOKBLodXzU8FwXlaw6-Uy2ull3q1qGFTbbLBYnVKwN2DAHHmqqXCKycDbIAoNHnqJ4GZzC_ZBs9qeASlvSaqAA1HTlJ4hkOKZiE/s1600/addgeom.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="312" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjP5YlLOHSYpchokSB4LCpuzQx2rXESPmltIiz1iL7yBOKBLodXzU8FwXlaw6-Uy2ull3q1qGFTbbLBYnVKwN2DAHHmqqXCKycDbIAoNHnqJ4GZzC_ZBs9qeASlvSaqAA1HTlJ4hkOKZiE/s400/addgeom.png" width="400" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Use group stats, applying average on both X and Y, then copy-paste the results in libreoffice. Save the file as csv</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_YCBHFlhPu52sqysJj639SW2oSLY84mviYXBxrKmvngdgG2q5rdpCWtFZ82dcyE0L5YacMnb3SuVJ7XC3TpMNC6kylo218WDyZD5MS9EEGIRZCfUfCPfsuMD5JcKEatq0WTm9bJ6LFww/s1600/group+stats.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="536" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_YCBHFlhPu52sqysJj639SW2oSLY84mviYXBxrKmvngdgG2q5rdpCWtFZ82dcyE0L5YacMnb3SuVJ7XC3TpMNC6kylo218WDyZD5MS9EEGIRZCfUfCPfsuMD5JcKEatq0WTm9bJ6LFww/s640/group+stats.PNG" width="640" /></a></div>
<div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie7L3ZkZF2_j80jIU7A8lj9LXF7qOvOe91e1eNsIBu6kFByuODKZkd91Ubo_6cV73x-LjtEXITvVheZ21UMCoJl6efYscEJG09FVVwiMCY-MNkRNXKFLommi3SamzbH2clGQ_peod7HBQ/s1600/midpoints.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie7L3ZkZF2_j80jIU7A8lj9LXF7qOvOe91e1eNsIBu6kFByuODKZkd91Ubo_6cV73x-LjtEXITvVheZ21UMCoJl6efYscEJG09FVVwiMCY-MNkRNXKFLommi3SamzbH2clGQ_peod7HBQ/s320/midpoints.PNG" width="262" /></a></div>
<div>
</div>
<div>
<br /></div>
<div>
Add the csv as a spatial layer</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTm61QztflsN-Eznylx79aSENm_-hR9wOh5M9RZV6gwlecocmPu6mlsOw3ngyFEabFbeAYOA875qlIMQ70R9MGSTo8s8oarrzxKzNS2tyVoe-UUjDRM2OZTKk4bY7q3BYBCSyJSJqDiq0/s1600/delimitedlayer.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="484" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTm61QztflsN-Eznylx79aSENm_-hR9wOh5M9RZV6gwlecocmPu6mlsOw3ngyFEabFbeAYOA875qlIMQ70R9MGSTo8s8oarrzxKzNS2tyVoe-UUjDRM2OZTKk4bY7q3BYBCSyJSJqDiq0/s640/delimitedlayer.PNG" width="640" /></a></div>
<div>
</div>
<div>
<br /></div>
<div>
Here we are !</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHZFeCZuWHq3m5hWmxANWkJBVoFFBS957_3E6DnIWMAGCTbe8jdHlQS5CfnNlQU6fKErPBzTbfe7LShU6ITLlyxLVn5pp6jjth-ZIQpYDH99qtHzt2vWjXbTKCaBWkU-EDk7VaW2IE0Mc/s1600/resultat.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="380" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHZFeCZuWHq3m5hWmxANWkJBVoFFBS957_3E6DnIWMAGCTbe8jdHlQS5CfnNlQU6fKErPBzTbfe7LShU6ITLlyxLVn5pp6jjth-ZIQpYDH99qtHzt2vWjXbTKCaBWkU-EDk7VaW2IE0Mc/s640/resultat.PNG" width="640" /></a></div>
<div>
</div>
<div>
<br /></div>
<div>
<br /></div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-44773271627199062182013-07-28T05:40:00.000-07:002013-09-07T01:01:04.616-07:00Un petit peu de "geohacking" et de scraping, da(o)rling?<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihtd9El7Q2OqGeOalMekDd0PUjt51jjwL9Bpyikf_2XheIQEoQJ8obNaX5CddF9FVIkp0ACrGC7zooUS2k5y37UfY7PnXV-d-tF-1dWNFsZOh0FygoBDstJP-A4S3Z8wM_NgHiBjwBnk4/s1600/soccer_4d1a47.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="194" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihtd9El7Q2OqGeOalMekDd0PUjt51jjwL9Bpyikf_2XheIQEoQJ8obNaX5CddF9FVIkp0ACrGC7zooUS2k5y37UfY7PnXV-d-tF-1dWNFsZOh0FygoBDstJP-A4S3Z8wM_NgHiBjwBnk4/s200/soccer_4d1a47.png" width="200" /></a></div>
<span style="text-align: center;">Cet article, c'est un peu "Les cartogrammes de Dorling pour les Nuls". Après avoir introduit les principes qui se cachent derrière ce concept cartographique très original, nous créerons une carte du nombre de clubs de football en France récupérés par une méthode de scraping selon ce mode de représentation. Dans ce post, il sera question de spatialisation et aussi un peu de "</span><i style="text-align: center;">hacking" </i><span style="text-align: center;">sous plusieurs formes.</span><br />
<br />
<br />
<br />
<br />
<br />
<a name='more'></a><b><span style="color: #e69138;"><br /></span></b>
<b><span style="color: #e69138;"><br /></span></b>
<b><span style="color: #e69138;">Les cartogrammes de Dorling ou les polygones qui ronflent (rrrond-rrrond)</span></b><br />
<b><span style="color: #e69138;"><br /></span></b>
Le Docteur <a href="http://en.wikipedia.org/wiki/Danny_Dorling">Daniel Dorling</a> avait élaboré <a href="http://qmrg.org.uk/files/2008/11/59-area-cartograms.pdf">une méthode de cartogrammes très originale</a> visant à présenter des valeurs statistiques de façon très épurée. Son idée était de s'affranchir de la forme des objets lorsque cette dernière présentait peu d'intérêt, en la travestissant sous la forme de la primitive géométrique la plus simple qui existe: le cercle. Sa méthode préserve la topologie des objets et prévient les recouvrements. Les polygones sont donc très bien déguisés.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.csiss.org/classics/archive/cartogram.html"><img border="0" height="297" src="http://www.csiss.org/classics/archive/images/compare.gif" width="400" /></a></div>
<br />
Sur son blog, Jim Valladingham présente <a href="http://indiemaps.com/blog/2008/04/cartogram-design/">un cube cartogrammique</a> qui figure les axes de représentation possibles. Les cartogrammes de Dorling se situeraient dans le coin avant-bas-droit, en cela qu'ils préservent la topologie des objets tout en les libérant de leur complexité géométrique.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://indiemaps.com/blog/2008/04/cartogram-design/"><img border="0" height="295" src="http://indiemaps.com/images/cartcube.png" width="320" /></a></div>
<br />
<span style="color: #e69138;"><b>Les cartogrammes de Dorling pour les Nuls</b></span><br />
<br />
Jim Valladingham avait <a href="http://indiemaps.com/blog/2008/01/dorlingpy/">porté vers python</a> ainsi que diffusé un script en C transmis par le Dr Dorling. Toutefois, une contrainte de ce script était qu'il ne consommait pas et ne produisait pas de fichiers géographiques. De plus, en entrée, le format était très spécifique et propriétaire.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg92iH5gy-_PX_vYWIurx5pdKw7OeZkLpyG57zL9Ebje3jRSYbYLvUAspRzvldSsAHzbkvVewP-uR9jViULofEssVjbJxwjv4JHQnX-CEB0wLy0FuuN7t8-6WY8YhjY-5T0mLnDxXFBv7k/s1600/jim.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="70" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg92iH5gy-_PX_vYWIurx5pdKw7OeZkLpyG57zL9Ebje3jRSYbYLvUAspRzvldSsAHzbkvVewP-uR9jViULofEssVjbJxwjv4JHQnX-CEB0wLy0FuuN7t8-6WY8YhjY-5T0mLnDxXFBv7k/s400/jim.jpeg" width="400" /></a></div>
<br />
J'ai donc tenté un portage du code vers R permettant l'intégration et la production de fichiers géographiques de tous les types supportés par OGR.<br />
<br />
A partir du code, j'ai essayé de comprendre de quelle façon ces cartogrammes étaient générés. Ce sont ces principes que je vais vous présenter à présent. En voici un schéma simplifié.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpE-zU0Tvai4MbBUZTojKilEruxNX8k4Dm5Q6sU9dyBHfKDaONF4KtpJxFPxaAfzBTRSUHJYbcIb1SWF6Ob1kvE_EkVtktfG6la3nX3yvQdz8MfhCV1cdnjEFWjVI2SQ-jFoo0ATMKPYw/s1600/dorling1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="376" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpE-zU0Tvai4MbBUZTojKilEruxNX8k4Dm5Q6sU9dyBHfKDaONF4KtpJxFPxaAfzBTRSUHJYbcIb1SWF6Ob1kvE_EkVtktfG6la3nX3yvQdz8MfhCV1cdnjEFWjVI2SQ-jFoo0ATMKPYw/s640/dorling1.jpg" width="640" /></a></div>
<br />
<ul>
<li><b><span style="color: orange;">(1)</span></b> Dans un premier temps, il nous faut construire le réseau topologique de nos objets géographiques. Aussi, on détermine les centroïdes de ces polygones. Chacun est distant du voisin selon une distance R.</li>
<li><b><span style="color: orange;">(2)</span></b> Une fois cela réalisé, on regarde quelles sont les valeurs numériques affectées à chacun des points. Ces dernières constituent les surfaces des cercles desquelles on dérive les rayons que nous appellerons R'.</li>
<li><b><span style="color: orange;">(3 et 4)</span></b> En toute logique, pour que les cercles ne se recouvrent pas, il faudrait appliquer un ratio à nos rayons de telle sorte à ce qu'on puisse ramener la somme des rayons à la somme des distances entre les points. C'est l'étape de "<b>scaling</b>".</li>
<li><b><span style="color: orange;">(5)</span></b> Cependant, des recouvrements peuvent quand même apparaître selon la configuration du réseau topologique. Aussi, on va appliquer des forces d'attraction ainsi que de répulsion de sorte à éloigner les cercles voisins qui se recouvrent et rapprocher ceux qui présentent des lacunes. C'est l'étape de "<b>shifting</b>".</li>
</ul>
<div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgacYU82q9BvjkJc5EyTFPTBisauwLYFe8I2gPzG_NrU9R12ML8yH2ZKknURuZ2hFwtt_4FZfxUyBQ_BXhbU5h7QUdD0KWxuwZOPS-ogmD4MWpiMy4a2XblrYgcz4pdiAkFjehw49QFXN8/s1600/code.jpeg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgacYU82q9BvjkJc5EyTFPTBisauwLYFe8I2gPzG_NrU9R12ML8yH2ZKknURuZ2hFwtt_4FZfxUyBQ_BXhbU5h7QUdD0KWxuwZOPS-ogmD4MWpiMy4a2XblrYgcz4pdiAkFjehw49QFXN8/s640/code.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Extrait du document technique de Daniel Dorling mentionnant les forces d'attraction et de répulsion</td></tr>
</tbody></table>
<br /></div>
Histoire de mieux comprendre le <i>shifting</i>, prenons une métaphore et imaginons des boules magnétiques. Une boule distante se retrouve attirée par les autres tandis qu'une autre qu'on laisse tomber sur le tas se fraiera une place entre les voisines. Le processus est itératif car le fait de déplacer une boule occasionnera le bousculement d'autres, etc...On s'arrête seulement lorsqu'on a trouvé la configuration optimale pour laquelle le recouvrement et le rapprochement sont minimaux.<br />
<div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX-ptne3ZVKj5NK66TGdigPuWPO5sUT6gFD05YJQPmhYBIb6ItpZPoWyxQ7CFayRX7FmF0eiiKcmpyI6qLy9JUgBRICS05u-sZGtTVBxEn8uAw1-6Gb4Cg6D3tawITgbOVdedm0kbZ5WU/s1600/attraction.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="280" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX-ptne3ZVKj5NK66TGdigPuWPO5sUT6gFD05YJQPmhYBIb6ItpZPoWyxQ7CFayRX7FmF0eiiKcmpyI6qLy9JUgBRICS05u-sZGtTVBxEn8uAw1-6Gb4Cg6D3tawITgbOVdedm0kbZ5WU/s400/attraction.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">(Un élève de 3e aurait pu faire ce schéma)</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
<span style="color: #e69138;"><b>Les terrains de foot moissonnés</b></span><br />
<br />
La figure circulaire me faisait penser au ballon rond. Le site <a href="http://www.le-footballeur.com/">le-footballeur.com</a> présente un annuaire des clubs de football en France depuis lequel j'ai appliqué des méthodes de <a href="http://fr.wikipedia.org/wiki/Web_scraping">scraping</a> visant à récupérer le nombre de clubs par département.<br />
<br />
<a href="http://www.le-footballeur.com/clubs_football-liste-departement.php">Une page</a> liste tous les départements pour lesquels des résultats existent. Le plugin Firefox <a href="https://addons.mozilla.org/fr/firefox/addon/firebug/">Firebug </a>m'indique que les urls sont dans un bloc div avec attribut align égal à left.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJn2flhCpQGpD8KCaO-thW9Q18v3ICuXCKs-vLPtzQGoN7QbCHe1IvuNKCSTvEsI2gV9GoApQd1nkTJ-Ml9heCOuRRz2i2Jw5NCs223b3POs2k7RcyVnkaZRm6j0iC7gnOXK_uCBiTnH0/s1600/scrape1.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJn2flhCpQGpD8KCaO-thW9Q18v3ICuXCKs-vLPtzQGoN7QbCHe1IvuNKCSTvEsI2gV9GoApQd1nkTJ-Ml9heCOuRRz2i2Jw5NCs223b3POs2k7RcyVnkaZRm6j0iC7gnOXK_uCBiTnH0/s400/scrape1.jpeg" width="400" /></a></div>
<br />
<br />
Une requête <a href="http://fr.wikipedia.org/wiki/XPath">xpath</a> appliquée à la page me permet d'extraire les urls.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxmPizklAfKNCPoX8v0G7PZXBiUtwChBb0bxLt9e06wK5PAxUkQyPA4RcT9Q6v0HBNuAp81H9s_V5wkhspLOyd369qXtWr5yCwx1jFBwBsGcX45EO8R9i9ejksz66zKTZ2K8DJKKss5g0/s1600/urls.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="52" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxmPizklAfKNCPoX8v0G7PZXBiUtwChBb0bxLt9e06wK5PAxUkQyPA4RcT9Q6v0HBNuAp81H9s_V5wkhspLOyd369qXtWr5yCwx1jFBwBsGcX45EO8R9i9ejksz66zKTZ2K8DJKKss5g0/s640/urls.jpeg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
A présent, extrayons les informations de chacune des pages. Si l'on ouvre celle de Paris, on voit que les informations sont présentes dans un bloc div qui suit un formulaire. </div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzmwO4LnWFHdSHeLFlpmWH6t4Y1EMNmCB3FQOpbC-Qrr8ewwMB0bwZ4v_UpgVVsFyj5H5Dfk2wZyxpQIgqQqaoxznRoGpb37btKlawevt-0lQV2g-J04WkS_AUVNOJx8NgMt1QcDdDnUc/s1600/scrape2.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="247" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzmwO4LnWFHdSHeLFlpmWH6t4Y1EMNmCB3FQOpbC-Qrr8ewwMB0bwZ4v_UpgVVsFyj5H5Dfk2wZyxpQIgqQqaoxznRoGpb37btKlawevt-0lQV2g-J04WkS_AUVNOJx8NgMt1QcDdDnUc/s400/scrape2.jpeg" width="400" /></a></div>
<br />
<br />
La requête xpath suivante me donne le contenu du bloc div sur lequel j'applique une expression régulière pour récupérer le nombre de clubs.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhylL9ToN6SfzBYuFu5oAPGRLF9BaPhk9u0iHEIz4xmfEIJ3x1wOUCgCZ_0UigdZ5exT7E10YUh7-jiTL-1mR-Ubp1GK3SsXkxuurgZ3txtuNyrRvQCm3waeSsMTlvHgjowmwew8YYs6oo/s1600/cblubs.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="28" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhylL9ToN6SfzBYuFu5oAPGRLF9BaPhk9u0iHEIz4xmfEIJ3x1wOUCgCZ_0UigdZ5exT7E10YUh7-jiTL-1mR-Ubp1GK3SsXkxuurgZ3txtuNyrRvQCm3waeSsMTlvHgjowmwew8YYs6oo/s640/cblubs.jpeg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Une fois que le nombre de clubs a été associé à mes objets géographiques, nous pouvons lancer la fonction de Dorling que j'ai créée.<br />
<br />
<div style="overflow: auto;">
<div class="geshifilter">
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWSukdedk_mrW4T14FvpUorDKDt-xR3ENFft-5pMv1j8gxVpPUSAgEtw4Vge5rC8GDZCvpFhYyzyTgPtT8GPBzziJGJUvZdmF3MH0YFOe44zbDJHKxuDhu_JbZxKq8nOLl7c7jZ-nS9hM/s1600/params.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="83" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWSukdedk_mrW4T14FvpUorDKDt-xR3ENFft-5pMv1j8gxVpPUSAgEtw4Vge5rC8GDZCvpFhYyzyTgPtT8GPBzziJGJUvZdmF3MH0YFOe44zbDJHKxuDhu_JbZxKq8nOLl7c7jZ-nS9hM/s400/params.jpeg" width="400" /></a></div>
<pre class="r geshifilter-R" style="font-family: monospace;"></pre>
</div>
</div>
<ul>
<li><b>nrescales</b> correspond au nombre de modulations du ratio à appliquer.</li>
<li><b>niter </b>correspond au nombre d'itérations que l'on va appliquer jusqu'à trouver le positionnement optimal.</li>
<li><b>tol </b>correspond au taux de recouvrement qui nous semble acceptable.</li>
</ul>
<div>
La fonction sera d'autant plus rapide que le nombre d'itérations et de modulations du ration sera petit, et que la tolérance sera élevée.</div>
<div>
<br /></div>
En sortie, cette fonction me donne la position xy des points ainsi que le rayon affecté à chacun.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsK8oVwm47OorpDMRXmMvBuq2vK9JMRPKGUN_qegWCZmDCmn71CPEFUCsmqBLQminlzk_FOcVQfAKrB0YVQNMyLMVsylZUrg3G_AU3YF66YQd9SCPmjBtflLYyiAzMIPgKDVhyLbxNqds/s1600/writeOGR.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="38" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsK8oVwm47OorpDMRXmMvBuq2vK9JMRPKGUN_qegWCZmDCmn71CPEFUCsmqBLQminlzk_FOcVQfAKrB0YVQNMyLMVsylZUrg3G_AU3YF66YQd9SCPmjBtflLYyiAzMIPgKDVhyLbxNqds/s640/writeOGR.jpeg" width="640" /></a></div>
<br />
Comme mentionné précédemment, l'étape de <i>shifting </i>au cours de laquelle des forces d'attraction et de répulsion sont appliquées entraîne le déplacement des points (par conséquent, adieu le positionnement absolu ! (ce qui peut être problématique)). Cette image présente les décalages induits:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8vUi6mbfnvNhCoufN4Ej5MthHBUW6B4LJaEiY9S_M4oi2PGQkYmE-YZQgi_5qztBdu5Ft1CV9JB1c91LxahDPrDt7Y72L-4RS11_mJfOwpulh7KyrqxpbgiOFxqDQ5gqjmtCJ5KxpZCs/s1600/Rplot02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8vUi6mbfnvNhCoufN4Ej5MthHBUW6B4LJaEiY9S_M4oi2PGQkYmE-YZQgi_5qztBdu5Ft1CV9JB1c91LxahDPrDt7Y72L-4RS11_mJfOwpulh7KyrqxpbgiOFxqDQ5gqjmtCJ5KxpZCs/s320/Rplot02.png" width="320" /></a></div>
<br />
<b><span style="color: #e69138;">Des ballons de foot stylés</span></b><br />
<br />
Le site <a href="http://thenounproject.com/">The Noun Project</a> présente de nombreux symboles SVG dans plein de thématiques. Une recherche sur "soccer" m'a donné toutes sortes d'images de ballons. Comme dans un magasin de sport, je n'ai eu qu'à faire mon choix.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://thenounproject.com/noun/soccer-ball/#icon-No2034" style="margin-left: auto; margin-right: auto;"><img border="0" height="307" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDnljeHx7LkiQFx7ewbYzz0v2u_HyxJb3aEpTcEr0xckTqcncAQwC2Mn83TPqFqwgv_YsV1IMm0e4KH9oYpsOMt3irLXA3f1u9pk1bmKF4qoc8DTPUpo8u-GOht_sggtNeu6BzLkf43Go/s400/soccer.jpeg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Pas mal, ce ballon de Laurent Patain</td></tr>
</tbody></table>
<br />
<br />
Via TileMill, j'ai stylisé la donnée en "propulsant" la largeur de mon symbole via l'attribut <i>radius</i> de ma couche géographique.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyM0I04zLB4wOVtR0b2lOi9hHt5rWdxNRqsva7-zgEaxVjOFRXb2mZRiLf_0V3LpMXmMLN8eNC8IWQ4RtT6WdEjxLWuvDit_DB8nQBEs5EC8w72h2HzbzbtDqxh1_xFnzkKI1tKABeEEg/s1600/tilemill.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="283" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyM0I04zLB4wOVtR0b2lOi9hHt5rWdxNRqsva7-zgEaxVjOFRXb2mZRiLf_0V3LpMXmMLN8eNC8IWQ4RtT6WdEjxLWuvDit_DB8nQBEs5EC8w72h2HzbzbtDqxh1_xFnzkKI1tKABeEEg/s400/tilemill.jpeg" width="400" /></a></div>
<br />
<br />
Voici au final une carte Dorling des clubs de football en France:<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihtd9El7Q2OqGeOalMekDd0PUjt51jjwL9Bpyikf_2XheIQEoQJ8obNaX5CddF9FVIkp0ACrGC7zooUS2k5y37UfY7PnXV-d-tF-1dWNFsZOh0FygoBDstJP-A4S3Z8wM_NgHiBjwBnk4/s1600/soccer_4d1a47.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="620" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihtd9El7Q2OqGeOalMekDd0PUjt51jjwL9Bpyikf_2XheIQEoQJ8obNaX5CddF9FVIkp0ACrGC7zooUS2k5y37UfY7PnXV-d-tF-1dWNFsZOh0FygoBDstJP-A4S3Z8wM_NgHiBjwBnk4/s640/soccer_4d1a47.png" width="640" /></a><br />
<br />
<br />
<span style="font-family: inherit;"><b>Remarque:</b></span><br />
<span style="font-family: inherit;">Une meilleure source de données aurait sans doute été le site de la FFF, notamment la page </span><a href="http://www.fff.fr/la-vie-des-clubs/resultats">http://www.fff.fr/la-vie-des-clubs/resultats</a>. Cependant, on ne peut y rechercher les clubs que par ville et non par département. A raison d'environ 36000 requêtes de récupération de page, le temps nécessaire à l'extraction était extrêmement long.<br />
<b><span style="color: red; font-family: Courier New, Courier, monospace;"><br /></span></b>
<b><span style="color: red; font-family: Courier New, Courier, monospace;">Do It Yourself</span></b><br />
<br />
<b><span style="color: orange;">Dorling</span></b><br />
<br />
<script src="https://gist.github.com/datagistips/6070719.js"></script><br />
<br />
<b><span style="color: orange;">Scraping</span></b><br />
<br />
<script src="https://gist.github.com/datagistips/6070778.js"></script><br />
<br />
<br />
<br /></div>
</div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-2174322441162164902013-03-28T03:21:00.000-07:002013-03-29T04:54:37.355-07:00Cartogrammes en Bois<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheNQT_8OX9ckrBaZKmUd5rehsR52fh4tbxpUXhYwcXp-ooTP1_MmDuF_0mL-IxikwD_ggAAFqlwA1kX1L98J6aH14ZflgGRMPIty-BB1dy1Po66FbQW5jE05WJJJxSXyvAf-MQdj_Gh4g/s1600/thumb_6456d9.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheNQT_8OX9ckrBaZKmUd5rehsR52fh4tbxpUXhYwcXp-ooTP1_MmDuF_0mL-IxikwD_ggAAFqlwA1kX1L98J6aH14ZflgGRMPIty-BB1dy1Po66FbQW5jE05WJJJxSXyvAf-MQdj_Gh4g/s200/thumb_6456d9.png" width="168" /></a></div>
<i><b>Que ne te fait-on pas subir, Ôôô, sacro-sainte Géométrie!</b></i><br />
De plus en plus, on remarque des transgressions cartographiques qui, soit altèrent la forme des objets géographiques, soit la simplifie à l'extrême. Dans certains cas, la géométrie importe peu car on s'attache plutôt à l'inter-relation des objets. C'est pourquoi on peut envisager des procédés dénaturants, surtout s'ils sont propulsés par des données. Nous allons explorer ceci au travers de certains types de cartogrammes ainsi que d'une carte appliquée à l'environnement: ça donnerait quoi, si l'on grignotait la surface des départements jusqu'à ce qu'elle corresponde à celle de ses forêts?<br />
<div class="" style="clear: both; text-align: left;">
</div>
<a name='more'></a><br />
<div class="separator" style="clear: both; text-align: left;">
<b><span style="color: #e69138;">Représentation de variables continues</span></b></div>
<b><span style="color: #e69138;"><br /></span></b>
Différents moyens existent pour traduire des variables quantitatives continues au niveau d'objets géographiques. Ces différents moyens sont très bien décrits dans le livre de référence de sémiologie graphique de Jacques Bertin, livre dont j'aime bien exposer la couverture à défaut de l'avoir lu.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://ecx.images-amazon.com/images/I/41SVS6TG2KL._SL500_AA300_.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="200" src="http://ecx.images-amazon.com/images/I/41SVS6TG2KL._SL500_AA300_.jpg" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">La sémiologie graphique, de Jacques Bertin</td></tr>
</tbody></table>
<br />
<span style="color: #e69138;">Méthodes classiques</span><br />
<br />
Prenons le cas de polygones, on pourra jouer sur les couleurs en jouant sur la saturation ou la luminosité (value en anglais). La saturation correspond à la quantité de pigments gris que vous mélangerez à votre teinte de base (hue en anglais).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiODhIL56BTsFccFX61uTZRb0bR7e3F2_P5erECXTdFgOQqanpYfA1k60q6mesNKcBjOThxi5pswuRn_8YolxHq_16k0PVS21dcHeV418p3ujfDsxYu-rkbq1cgscefgb5aAB29wva67Bk/s1600/luminositesaturation.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiODhIL56BTsFccFX61uTZRb0bR7e3F2_P5erECXTdFgOQqanpYfA1k60q6mesNKcBjOThxi5pswuRn_8YolxHq_16k0PVS21dcHeV418p3ujfDsxYu-rkbq1cgscefgb5aAB29wva67Bk/s320/luminositesaturation.png" width="320" /></a></div>
<br />
On pourra aussi jouer sur les trames qui composent l'objet: plus ou moins resserrées, de largeur, voire d'orientation variable.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEithiL8jBMeeD_EvlUYCsz8l-jWU0y8C2i_raP4As9JaRsnKo6MB7cpNCp_Qv_3J_-AeQD3Y4GQULlG-xBCMlxj49bPP6FdC1d-yzbedZVJKaHyU5SrzDpDk5S5z0TdVNyJwmdFHCcCOjk/s1600/cheval.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="252" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEithiL8jBMeeD_EvlUYCsz8l-jWU0y8C2i_raP4As9JaRsnKo6MB7cpNCp_Qv_3J_-AeQD3Y4GQULlG-xBCMlxj49bPP6FdC1d-yzbedZVJKaHyU5SrzDpDk5S5z0TdVNyJwmdFHCcCOjk/s320/cheval.png" width="320" /></a></div>
<br />
<br />
On pourra aussi jouer sur les contours mais cela est moins fréquent dans les cartes car seul ce que contient un polygone nous intéresse en général.<br />
<br />
Tous ces critères peuvent d'ailleurs se combiner afin de faire apparaître plusieurs variables au sein d'un même objet géographique et obtenir des visualisations multidimensionnelles. Imaginez qu'on additionne couleur + orientation[trame] + espacement[trame] + épaisseur[trame], cela permet de visualiser 4 variables en même temps (mais il est déconseillé de mettre cela en pratique sauf si vous avez de l'efferalgan sous la main)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP9g1sHbPIlsUxX6c2qgYpUHGFh9pkxK1hjur29MXJfr-_XGdbkTyrRn5pfvIgSuEbe3fvlApflFYlePHgk9BDTTEa0erv60OyMfH1i8gjMYxNa2VFUbWPBRd24zkwsGwNE5VPNMM_mSk/s1600/combinaison.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="103" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP9g1sHbPIlsUxX6c2qgYpUHGFh9pkxK1hjur29MXJfr-_XGdbkTyrRn5pfvIgSuEbe3fvlApflFYlePHgk9BDTTEa0erv60OyMfH1i8gjMYxNa2VFUbWPBRd24zkwsGwNE5VPNMM_mSk/s200/combinaison.jpg" width="200" /></a></div>
<span style="color: #e69138;">Géométrie variable</span><br />
<span style="color: #e69138;"><br /></span>
<span style="color: #e69138;"><i>Cartogrammes de Dorling</i></span><br />
<span style="color: #e69138;"><br /></span>
Il existe un paramètre dont on a peu parlé jusqu'à récemment car ce sont surtout les capacités de calcul de nos machines qui ont permis de l'exploiter. Il s'agit de la géométrie.<br />
<br />
On pourra remplacer les objets géographiques par des cercles en évitant les recouvrements et en préservant les relations. On appelle cela les cartogrammes de Dorling. Ces cartogrammes s'obtiennent grâce à un processus itératif semblable à ce qui se passe lorsque vous empilez des boules les unes au-dessus des autres dans une boîte dont vous enlevez ensuite les bords. On associe couramment la largeur de ces boules à des variables quantitatives.<br />
<br />
On pourrait d'ailleurs aller dans le multi-dimensionnel en remplaçant chaque cercle par un camembert. Cela dit, si pas mal de personnes aiment le camembert, les pizzas, les tartes - enfin, tout ce qui est rond et qui se découpe - <a href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b0120a520831b970b-popup" target="_blank">les pie charts sont loin de faire l'unanimité</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizifSQ7QXLmQbXkyhv05evSr6eJD5I63sLki-lbxpKiWYIbWD5euVgJPqvc8uhYmLfawGiyW6PIlu_oj5NmX2ZcwoQtfCWadssSWGpGCLcvr2ZYt26W2tI_J8uNsu5bCL-i8sDoOJEpjc/s1600/corling.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="155" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizifSQ7QXLmQbXkyhv05evSr6eJD5I63sLki-lbxpKiWYIbWD5euVgJPqvc8uhYmLfawGiyW6PIlu_oj5NmX2ZcwoQtfCWadssSWGpGCLcvr2ZYt26W2tI_J8uNsu5bCL-i8sDoOJEpjc/s400/corling.png" width="400" /></a></div>
<br />
<br />
<i style="color: #e69138;">Cartogrammes de Demers</i><br />
<i style="color: #e69138;"><br /></i>
On pourrait aussi remplacer ces cercles par des carrés. Le même processus itératif s'applique mais les algorithmes permettant de détecter les collisions diffèrent afin de prendre en compte la spécificité géométrique des carrés. On appelle ces rendus les cartogrammes de Demers.<br />
<br />
Dans ce cas, l'astuce pourrait alors consister à intégrer des treemaps!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd8W20ZkuRac49VgcV-iypiiE8cCayTtHrnRGqwoGQH4T3wCXeGTqGwQY3vTwYFdiH_vNA8xqXxgn0cS5teBiLkEZ83w24GWcVxfvMYd8wM4Du1Ie4Swg-KXXw78lD61D4gNJ5Vww6RUE/s1600/demers.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="130" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd8W20ZkuRac49VgcV-iypiiE8cCayTtHrnRGqwoGQH4T3wCXeGTqGwQY3vTwYFdiH_vNA8xqXxgn0cS5teBiLkEZ83w24GWcVxfvMYd8wM4Du1Ie4Swg-KXXw78lD61D4gNJ5Vww6RUE/s400/demers.png" width="400" /></a></div>
<br />
<br />
L'avantage des cartogrammes de Dorling et de Demers est qu'ils permettent de réduire considérablement la granularité des informations graphiques en simplifiant à l'extrême la forme des objets géographiques, ces derniers devenant des primitives géométriques. Aussi, ces cartogrammes permettent de rendre aisément des proportions tout en conservant les relations entre objets.<br />
<br />
<i><span style="color: #e69138;"><br /></span></i>
<i><span style="color: #e69138;">Cartogrammes dicontigus</span></i><br />
<i><span style="color: #e69138;"><br /></span></i>
Mise à part la substitution d'objets par des formes simples, on pourrait aussi appliquer des transformations affines (je ne parle pas ici de l'affinage du camembert de Dorling).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiufzL2D4maiRFjnvjtBcPX6Nhz8HOLGu6zkllphNZXt1uuQwS92Ll-arv9MMXBDK3XDfp2mATu9GddzFSJavsogiz_TpTlfcwZJUgzLC3ziRkX0iT2ywWmYiRk7aQPN1hXjwIjUPpf1Hc/s1600/rotation.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiufzL2D4maiRFjnvjtBcPX6Nhz8HOLGu6zkllphNZXt1uuQwS92Ll-arv9MMXBDK3XDfp2mATu9GddzFSJavsogiz_TpTlfcwZJUgzLC3ziRkX0iT2ywWmYiRk7aQPN1hXjwIjUPpf1Hc/s320/rotation.png" width="217" /></a></div>
<br />
<br />
Pour ce qui des translations et des rotations, le résultat est difficilement lisible. On préfère généralement le redimensionnement. Le résultat est ce qu'on appelle les cartogrammes discontigus car le fait de rapetisser les formes supprime les relations de voisinage.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="http://indiemaps.com/images/noncontiguous/oldPopulation.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="245" src="http://indiemaps.com/images/noncontiguous/oldPopulation.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 13px;">Nombre de personnes de 65 ans et plus - Jim Valladingham sur http://indiemaps.com/</td></tr>
</tbody></table>
<br />
Si la librairie D3 permet d'ores et déjà de <a href="http://strongriley.github.com/d3/ex/cartogram.html" target="_blank">réaliser ces différents types de cartogrammes,</a> je n'ai pas trouvé de fonction prête à l'emploi pour un outil libre de cartographie.<br />
<br />
<br />
<b><span style="color: #e69138;">Deux méthodes pour les cartogrammes discontigus</span></b><br />
<br />
Il existe deux méthodes pour réaliser ce type de cartogrammes.<br />
<br />
<span style="color: #e69138;">Echelonnage</span><br />
<span style="color: #e69138;"><br /></span>
La première conserve les caractéristiques géométriques de la forme, sa complexité, en lui appliquant un facteur d'échelle.<br />
<br />
Le principal avantage de cette technique est que la géométrie est préservée. On peut faire une analogie entre ce type de cartogramme et un jean's que vous retrouveriez rapetissé après lavage. Ce dernier garde bien sa forme mais sa taille change (c'est bête, vous ne pourrez alors plus le porter).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEMKZy3c8lJ_OnmltdOZw-Prn21zM2eDIsJHJntkFDMLUyYq-hD4qygEZkLHbCPvskO5MBNFClv1ef2DuoV9npFU90105rLoV0xj17QuP0V3WnYjdPUKQRiDEK6-rbNGStaDUwyIL_9D4/s1600/jean.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEMKZy3c8lJ_OnmltdOZw-Prn21zM2eDIsJHJntkFDMLUyYq-hD4qygEZkLHbCPvskO5MBNFClv1ef2DuoV9npFU90105rLoV0xj17QuP0V3WnYjdPUKQRiDEK6-rbNGStaDUwyIL_9D4/s400/jean.jpg" width="400" /></a></div>
<br />
<br />
Appliquer un facteur d'échelle à un objet de 1/2 ne suffit pas à diviser sa surface par 1/2. C'est bien plus compliqué que cela. Généralement, avant de réaliser ce genre de cartos, une normalisation des données est réalisée afin que le ratio maximal soit ramené à un mais cela ne résout pas le problème du ratio..<br />
<br />
Un inconvénient de cette méthode est que, dans les cas où la géométrie d'un objet est très complexe, il est possible que cette dernière recouvre celle de référence, voire empiète sur la voisine, ce qui rompt une certaine idée de l'esthétique.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIo-6p_ESm1vDtHtgqI228gOSanlUit7k3r3Tzj3vS-qtYLbjbLkJ_gWixvc5maNlYcDO9l6JWbHsZrEwCczY-1TKOBihJd4pP7J-1Y1pdSUcnQtf6aKXqUQXemVuNRGUbGkJ3TMxGoVU/s1600/voisin.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="191" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIo-6p_ESm1vDtHtgqI228gOSanlUit7k3r3Tzj3vS-qtYLbjbLkJ_gWixvc5maNlYcDO9l6JWbHsZrEwCczY-1TKOBihJd4pP7J-1Y1pdSUcnQtf6aKXqUQXemVuNRGUbGkJ3TMxGoVU/s200/voisin.png" width="200" /></a></div>
<br />
<br />
<span style="color: #e69138;">Erosion</span><br />
<span style="color: #e69138;"><br /></span>
La deuxième méthode utilise la méthode d'érosion. Elle consiste à éroder la forme jusqu'à obtenir une surface d'un certain ratio de la forme de référence.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDFIGDgpTpEqY-DM2aVGCmis-SLz7xP6DQlO4LNaghaKYkoMYDENqMg2XHTIMOef45HtWqnpZapaDaFJwKHDjzrbGIi93rmh2A3NV3H4JwbZcKN0cEGGYd5qBfmvqLd2VygPF5Duw9kzs/s1600/erosio.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDFIGDgpTpEqY-DM2aVGCmis-SLz7xP6DQlO4LNaghaKYkoMYDENqMg2XHTIMOef45HtWqnpZapaDaFJwKHDjzrbGIi93rmh2A3NV3H4JwbZcKN0cEGGYd5qBfmvqLd2VygPF5Duw9kzs/s200/erosio.png" width="126" /></a></div>
<br />
<br />
Comme je ne connais pas l'équation qui permet de connaître la distance d'érosion à appliquer afin d'aboutir à une surface donnée, j'ai utilisé en remplacement une méthode itérative qui utilise un pas d'érosion fixé par l'utilisateur.<br />
<br />
<i>Le code pour chacune des deux méthodes sous R est disponible en bas.</i><br />
<br />
<b><span style="color: #e69138;"><br /></span></b>
<b><span style="color: #e69138;">Si l'on réduisait la surface des départements à la surface de leur forêt</span></b><br />
<br />
<span style="color: #e69138;">Le choix de cartogrammes dicontigus</span><br />
<span style="color: #e69138;"><br /></span>
Une donnée m'a intéressé. Il s'agissait de la surface de forêt dans chacun des départements en 2008. Je l'ai récupérée sur le site de Data Publica qui est le plus grand annuaire français de données ouvertes (cette donnée vient à l'origine d'<a href="http://agreste.agriculture.gouv.fr/" target="_blank">Agreste</a>).<br />
<br />
<span style="font-size: x-small;"><a href="http://www.data-publica.com/opendata/4477--donnees-statistiques-historiques-sur-les-forets-en-france-de-1830-a-2008">http://www.data-publica.com/opendata/4477--donnees-statistiques-historiques-sur-les-forets-en-france-de-1830-a-2008</a></span><br />
<br />
Le nombre de méthodes de visualisation possibles pour une variable continue est si grand qu'il convient de sélectionner celle qui retranscrira le mieux possible le phénomène étudié.<br />
<br />
La méthode de cartogramme discontigu par érosion s'associe bien à l'idée de grignotage.<br />
<br />
J'ai donc choisi d'utiliser ce procédé afin de figurer la surface boisée tout en signifiant le phénomène de perte d'espaces naturels. La méthode a consisté à réduire la surface du département jusqu'à ce qu'elle corresponde à peu près à celle de ses forêts. Ainsi, il est aisé de comparer le département et sa forêt.<br />
<br />
Voici le résultat obtenu après érosion. J'ai également fait figurer le résultat obtenu avec échelonnage de la donnée.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKmda-oesEclhM9AhwGpyz7MpLt1HkNMUApNdJeUAp_mDlsGE5uJmwMLLaP18RmaWxHLqmmtzQKCwPnG9sZVUP27cDSbHWAAdk4AhV7BZM3f26ab4L2BBX47goDCd4ptWh8_5PlgiPOOo/s1600/carte.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="377" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKmda-oesEclhM9AhwGpyz7MpLt1HkNMUApNdJeUAp_mDlsGE5uJmwMLLaP18RmaWxHLqmmtzQKCwPnG9sZVUP27cDSbHWAAdk4AhV7BZM3f26ab4L2BBX47goDCd4ptWh8_5PlgiPOOo/s400/carte.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Proportion de surface boisée sous la forme de cartogrammes (en vert foncé, méthode érosive; en vert clair, échelonnage)</td></tr>
</tbody></table>
<br />
<span style="color: #e69138;">De la donnée au rendu cartographique</span><br />
<span style="color: #e69138;"><br /></span>
Le rendu est assez pauvre, avec un impact cognitif assez faible. La donnée mérite d'être habillée pour être sortable (sinon, c'est comme inviter un naturiste à une soirée déguisée).<br />
<br />
<i><span style="color: #e69138;">TileMill</span></i><br />
<br />
J'étais tombé il y a un moment sur un exemple plutôt impressionnant de représentation de données de sécheresse sur les USA<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://dribbble.s3.amazonaws.com/users/22601/screenshots/694207/drought-400x300.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="300" src="http://dribbble.s3.amazonaws.com/users/22601/screenshots/694207/drought-400x300.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Carte de la sécheresse aux Etats-Unis - John Dilworth</td></tr>
</tbody></table>
<br />
Le réalisme de cette carte provient en fait de l'emprunt d'images réelles correspondant à la thématique sécheresse (le sol desséché et l'herbe, par contraste) déclinées en motifs utilisés en trame.<br />
<br />
Le logiciel TileMill a été utilisé pour se faire car il est à ma connaissance un des seuls outils cartographiques qui permette d'utiliser des images en tant que trame ou de marqueur. Il permet aussi de superposer des couches de façon très sophistiquée grâce à différents modes de fusion (<a href="http://nyalldawson.net/2013/03/coming-soon-in-qgis-2-0-blend-modes-for-layers/" target="_blank">dont devrait se doter à l'avenir QGIS 2.0</a>, patience).<br />
<br />
J'ai donc décidé d'utiliser TileMill pour habiller ma donnée.<br />
<br />
<br />
<i><span style="color: #e69138;">Réalisation de motifs</span></i><br />
<br />
Dans un premier temps, il me fallait trouver des motifs qui correspondraient pour le premier à la forêt, pour le deuxième, au sol. Je suis allé sur le portail <a href="http://search.creativecommons.org/?lang=fr" target="_blank">Creative Commons Search</a> afin de trouver des images libres de droit.<br />
<br />
Voici les images que j'ai trouvées:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQG8U3af3tEAd0b9YTsk1LMB2EXcBvRrcLXvUAjg0_0alKpeuZBCW4NLWtn9Q_6lyAH2BrQTnMQ1TpuDsSP2ybWAul1UtWFTvPaWWay_h9LP75TLHU5cKycgsOsM_8ckYp5Tj_YsUxOIY/s1600/photos+de+base.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="322" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQG8U3af3tEAd0b9YTsk1LMB2EXcBvRrcLXvUAjg0_0alKpeuZBCW4NLWtn9Q_6lyAH2BrQTnMQ1TpuDsSP2ybWAul1UtWFTvPaWWay_h9LP75TLHU5cKycgsOsM_8ckYp5Tj_YsUxOIY/s640/photos+de+base.png" width="640" /></a></div>
<br />
Si l'on regarde la carte sur la sécheresse, on remarquera que les motifs semblent se répéter sans que l'on puisse les dissocier.<br />
<br />
Il existe une petite manipulation sous Gimp qui permet de rendre des images raccordables et aboutir à des motifs raccords.<br />
<br />
Voici les différentes étapes qui permettent d'obtenir des motifs depuis des images.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6G9Qf9lDYAbc92ROCYObF6xapw2j7B5GTJFFdfhuMAMyVdL8wsiK8vIqF8e9EhH4TKSyzpw4Qj8PmwXWxNk_8jeznpeBHfHUtwiAow9CH8jK8bV4w2CLnGT9sbqQlMqXsO1zfgVJW420/s1600/manips.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="276" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6G9Qf9lDYAbc92ROCYObF6xapw2j7B5GTJFFdfhuMAMyVdL8wsiK8vIqF8e9EhH4TKSyzpw4Qj8PmwXWxNk_8jeznpeBHfHUtwiAow9CH8jK8bV4w2CLnGT9sbqQlMqXsO1zfgVJW420/s640/manips.png" width="640" /></a></div>
<br />
<br />
<span style="color: #e69138;"><i>Habillage</i></span><br />
<br />
L'habillage de données sous TileMill se fait sous un langage apparent au Cascading Style Sheet appelé CartoCSS avec des feuilles de style portant le suffixe mss pour Map Syle Sheet. Les balises CartoCSS sont différentes de celles du CSS car spécifiques aux données géographiques. Par exemple, une, appelée <i>line-dasharray</i> permet de spécifier la taille et l'espacement des tirets d'une ligne; une autre, appelée <i>text-allow-overlap</i>, permet d'autoriser ou non le recouvrement des libellés.<br />
<br />
Voici la feuille de style de la carte:<br />
<br />
<script src="https://gist.github.com/datagistips/5259334.js"></script><br />
<br />
Et la carte:<br />
<br />
<a href="http://www.flickr.com/photos/10519370@N04/8596530483/" target="_blank" title="Surface boisée par département de mathieu rajerison, sur Flickr"><img alt="Surface boisée par département" height="475" src="http://farm9.staticflickr.com/8249/8596530483_46abf44dfe.jpg" width="500" /></a><br />
<br />
<br />
La cartographie nécessitait traditionnellement la maîtrise d'outils spécifiques qu'à peu près seuls les géomaticiens maîtrisaient. TileMill a ceci de révolutionnaire qu'il contient un langage permettant aux webdesigners de s'approprier la discipline. Il supprime une barrière technologique de taille qui séparait le graphisme sur le web et la cartographie. Des analystes et des graphistes peuvent collaborer plus facilement grâce à ce produit hybride.<br />
<b><span style="color: #e69138;"><br /></span></b>
<b><span style="color: #e69138;"><br /></span></b>
<b><span style="color: #e69138;">Code pour les cartogrammes</span></b><br />
<b><span style="color: #e69138;"><br /></span></b>
<script src="https://gist.github.com/datagistips/5262410.js"></script><br />
<br />
<br />
<br />harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com5tag:blogger.com,1999:blog-9055497882207462476.post-88422835360922374952013-01-27T22:22:00.000-08:002013-02-06T06:10:21.693-08:00Un atlas alphabétique du mondeEt si, cette année, pour épater vos amis, vous décidiez d'apprendre les noms de tous les pays?<br />
<br />
Avant d'entreprendre une telle chose, on serait déjà tentés de les lister par ordre d'alphabétique. Enfn, ce serait encore mieux si l'on pouvait ajouter quelques éléments de géographie, pour créer un atlas, finalement.<br />
<br />
C'est l'objet de la carte ci-dessous où les pays sont rangés par ordre alphabétique.<br />
<br />
Pas vraiment d'analyse à en tirer. On remarquera cependant qu'aucun pays ne commence par les lettres W et X et qu'au contraire, beaucoup de pays commencent par la lettre S (in-croy-able..).<br />
<br />
Pour réaliser cette petite carte, je me suis basé sur la couche "cultural" du site <a href="http://www.naturalearthdata.com/">Natural Earth</a> à une résolution de 1:110m. Celle-ci comporte 177 pays. A noter que l'ONU en compte 192 parmi lesquels Monaco, Saint-Marin, les îles Cook, le Vatican qui n'apparaissent pas sur ma carte. Mais, déjà, 177, ça en fait pas mal à mémoriser!..<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
A regarder, le soir, avant de dormir..<br />
<br />
Un petit peu de programmation sous R pour générer l'atlas ainsi que la carte du monde, puis une mise en page sous GIMP ont permis d'aboutir au résultat final.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://picasaweb.google.com/lh/photo/NkRDThycEWL--HD2pnqlDsMgbHW51AOnNtzKTxSCN0c?feat=directlink" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;" target="_blank"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAHHTdg9ktN_u9siNaBb475ZiOa2lp5gzZlyHfp4H4_UZhapR5Aht4MbtEOqttf0Gsf4PEnjeora0ClRQWPD0EHQcoyrUy4O9i-2CUfVAuWckSonESC6RgBKgPU0E6pMqpl0UvYSAHGDQ/s640/alphabet_final.png" width="568" /></a></div>
<br />
Et bien sûr, pour finir, le code:<br />
<br />
<a name='more'></a><br />
<br />
<br />
<script src="https://gist.github.com/4635619.js"></script>harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-23385203221582349402012-09-18T01:12:00.001-07:002013-02-06T06:10:58.170-08:00Les cartes typos, comment sonnent les communes de votre région?<div style="color: black;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTuzgY1HsdH81sH7ufLH4g7vYOuuMZqJMyEib8Dic8gRT72tbWEhZ4k8l0tdsZXHrmljY8ruQSIhXQoV3aYc-KNBUGM964niNtco4mdz6X81w13NsRBPYOdNlIy0ZDIz31LUgej6DtEtE/s1600/out_gimp2.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTuzgY1HsdH81sH7ufLH4g7vYOuuMZqJMyEib8Dic8gRT72tbWEhZ4k8l0tdsZXHrmljY8ruQSIhXQoV3aYc-KNBUGM964niNtco4mdz6X81w13NsRBPYOdNlIy0ZDIz31LUgej6DtEtE/s200/out_gimp2.png" width="183" /></a>Cet article parle du texte dans les cartes.Loin d'être un élément polluant, le texte peut véhiculer toute une palette de formes esthétiques ainsi que favoriser la perception de valeurs statistiques. Certaines réalisations cartographiques ne sauraient se passer de lui. C'est le cas d'une carte que nous essaierons de concevoir au sein de cet article au sujet de la dénomination des communes, de leur "son". Avant cela, nous aurons tenté d'introduire, modestement, l'univers des cartes typographiques.</div>
<div style="color: black;">
<br /></div>
<div style="color: black;">
<br /></div>
<div style="color: black;">
<br /></div>
<br />
<a name='more'></a><b style="color: orange;">Le texte au sein d'une carte</b><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnoil_Ol1L2hgnnnLSFPiDwgG-hKNY-Q31wAqBC8iY2ipUwstG7bayuklFiu0App6AnG5C68E_UD8Vzhnhqj1MTZPE_THhUMqayAlhRHPgSQGU2pp_wRcOZzsNNVgbyL1gXqRG6Ih4cyE/s1600/entonnoir.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnoil_Ol1L2hgnnnLSFPiDwgG-hKNY-Q31wAqBC8iY2ipUwstG7bayuklFiu0App6AnG5C68E_UD8Vzhnhqj1MTZPE_THhUMqayAlhRHPgSQGU2pp_wRcOZzsNNVgbyL1gXqRG6Ih4cyE/s400/entonnoir.png" width="285" /></a></div>
<br />
Ma définition d'une carte traditionnelle sera ici volontairement succinte. Selon moi, il s'agit à la base d'un agencement de formes, de couleur et de texte. La barre d'échelle est une forme rectangulaire assortie de libellés numériques. La fléche d'orientation est l'association d'une rosace de forme variable munie de la mention d'un ou de plusieurs points cardinaux.<br />
<br />
C'est la combinaison d'éléments picturaux et littéraux qui permet de fournir une information à celui qui lit la carte.<br />
<br />
Concernant la forme picturale, qu'elle soit ponctuelle, linéaire ou surfacique, sa forme, sa couleur, sa trame, sa densité, son angle de rotation peuvent servir de paramètres afin fournir une information numérique ou qualitative. Si cette dernière est décrite dans la légende, elle sera reçue sans faute par l'utilisateur. Si elle ne l'est pas, elle sera seulement perçue de manière subjective (avec parfois des risques d'interprétation).<br />
<br />
En fait, je ne fais ici que reprendre les idées formulées par Scott Mac Cloud dans son excellent "Understanding Comics", ouvrage qui pourra intéresser autant les férus de BDs que de design informationnel.<br />
<br />
<br />
<span id="goog_804504520"></span><span id="goog_804504521"></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3rQLleaH2kG5LhH0sChmcOi00bGMaYoG5p_eHFmtoi3Tav8UgYjhufVgksqDZBgCebOfCFi4YLGdAPm1oqUF-F1QlF_68Xynq-gltfIGbx9YYxz1TFh5HJubwejxqjgemSaeVkTArE4s/s1600/gestalt.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3rQLleaH2kG5LhH0sChmcOi00bGMaYoG5p_eHFmtoi3Tav8UgYjhufVgksqDZBgCebOfCFi4YLGdAPm1oqUF-F1QlF_68Xynq-gltfIGbx9YYxz1TFh5HJubwejxqjgemSaeVkTArE4s/s320/gestalt.png" width="320" /></a></div>
<br />
<br />
Tous les paramètres de représentation d'objets sont très bien décrits dans les ouvrages de sémiologie graphique tels que ceux de Jacques Bertin. Ils sont aussi officialisés dans des bouquins de design informationnel comme des "gestalt principles of design". <br />
<br />
La plupart du temps, ceux qui réalisent des cartes, notamment statistiques, négligent le texte au profit des éléments figuratifs. Le texte est souvent perçu comme un élément "polluant" qui va dissimuler la forme alors qu'en réalité, il la sert. La forme doit-elle primer sur le fonds, l'esthétique sur la limpidité de l'information?<br />
<br />
Ci-dessous figurent des cartes où le texte est mis en avant de manière inventive et esthétique. Il y est détourné de façon malicieuse de son usage courant ou bien, dans son agencement, mime la forme d'un objet.
<br />
<br />
- San-Francisco en noms de rue:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.axismaps.com/blog/2010/12/san-francisco-typographic-map/" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="211" src="http://www.axismaps.com/blog/wp-content/uploads/2010/12/blog2.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">San-Franciso Typographic Map by axismaps</td></tr>
</tbody></table>
<div>
<br />
- Les noms de groupes de musique au Royaume-Uni:</div>
<div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.blogger.com/.pello.co.uk" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="320" src="http://www.pello.co.uk/images/print-music-map-great-british-bands-art-by-pello.jpg" width="225" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Great British Bands by pello.co.uk</td></tr>
</tbody></table>
<br />
- Un carte réalisée avec des noms de films:</div>
<div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.wearedorothy.com/shop/film-map-original-open-edition" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="227" src="http://www.wearedorothy.com/uploads/uploads/777x553/Dorothy_0033_c%20Film%20Map.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Film Map by Dorothy Weare</td></tr>
</tbody></table>
<br />
- Les prénoms des Américains:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://ngm.nationalgeographic.com/2011/02/geography/usa-surnames-interactive" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="290" src="http://spatialanalysis.co.uk/wp-content/uploads/2011/01/NG_Surnames.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">USA surnames by National Geographic</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNPfRdwLZ1ckahxHszh9VM8MaEGbXhXh5bEjQmesD1iB7tnrZ-Kdi9DBoPLQ6yRc2Whv6GSK414xnc1CXbSZK3poX98OwOEL_tYuqeNvor8aqVzZzeBw4_1aLEZelPrECu6BHehS8pfmU/s1600/panneau.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
En fait, il y a tout autant de façons de manipuler le texte que les objets géométriques.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQOusRIHX4ZSvs0U9uaB4YSJE-4nftGZEbL05M4DgggO_mZ_avRvB98Qft4bOU6L7daTiWLCHnZN3XkyXLtmy0PTliROXFU4Aw_N7uF7khe0tIdrKI6dhQrmT2mnmpcoHGMzCgPtT0_8g/s1600/patati+patata.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQOusRIHX4ZSvs0U9uaB4YSJE-4nftGZEbL05M4DgggO_mZ_avRvB98Qft4bOU6L7daTiWLCHnZN3XkyXLtmy0PTliROXFU4Aw_N7uF7khe0tIdrKI6dhQrmT2mnmpcoHGMzCgPtT0_8g/s400/patati+patata.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<ul>
<li><b style="color: #9fc5e8;">couleur</b>: plus ou moins saturée, de teinte variable.</li>
<li><span style="font-size: large;">hauteur</span></li>
<li><span style="font-size: large;">l a r g e u r </span></li>
<ul>
<li><span style="font-size: large;"><span style="font-size: small;">hauteur et largeur peuvent être utilisées pour représenter un variable numérique (population, etc...)</span>
</span></li>
</ul>
<li><b>graisse: </b>pour mettre en valeur du texte en fonction d'une variable qualitative.</li>
<li>e s p a c e m e n t: il agit un peu comme la densité d'un semis de points ou l'espacement de hâchures</li>
<li><i>inclinaison:</i> il pourrait signifier une tendance binaire suivant si le texte est orienté à gauche ou à droite (appliqué aux résultats de vote). Il pourrait également signifier une notion de vitesse, d'avancement.</li>
<li>angle: selon moi, ce paramètre est à manier avec précaution, au risque d'attraper un torticolis.</li>
<li><span style="font-family: Verdana,sans-serif;">type de fonte</span>: une fonte véhicule une émotion, un univers. Par exemple, la fonte utilisée dans cette image rappelle les cartes au trésor.</li>
</ul>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.openstreetmap.fr/f/mapnik-sketchy-map_0.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="236" src="http://www.openstreetmap.fr/f/mapnik-sketchy-map_0.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Carte de pirate réalisée avec Mapnik</td></tr>
</tbody></table>
<br />
Il y a sûrement plein d'autres possibilités que je n'ai pas listées ici.<br />
<br />
<br />
<b style="color: orange;">Logiciels et typographie</b><br />
<br />
Les logiciels de dessin vectoriel tels qu'Adobe Illustrator ou Inkscape incorporent déjà toutes ces possibilités de lettrage.<br />
<br />
QGIS, le logiciel populaire de carto libre, dispose aussi telles fonctions: on peut choisir la fonte, la taille de la police, l'orientation du texte en fonction de valeurs.<br />
<br />
Un logiciel comme Processing va très loin dans ce domaine. Dans cette image réalisée avec l'outil de design génératif, les lettres nous permettent de lire un visage.<br />
<br />
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="500" mozallowfullscreen="mozallowfullscreen" src="http://player.vimeo.com/video/35662517" webkitallowfullscreen="webkitallowfullscreen" width="500"></iframe> <br />
<a href="http://vimeo.com/35662517">P_4_3_2_01</a> from <a href="http://vimeo.com/generativedesign">Generative Design</a> on <a href="http://vimeo.com/">Vimeo</a>.<br />
<br />
<b style="color: orange;"><br /></b>
<b style="color: orange;">Une carte des noms de commune</b><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTsMr3i0LTSrNM73In7_M10pk8ug_Mdsw8Wyp9_MdXxjKQ_1SSgvcERrCg0ksZOuQbKe7izNKHSQS6wRFl6UlxE6EkuzamYMm-bjo67PkJrFZDMp0VUtnxEscRZZxtFLuWnBgL2TkPEns/s1600/bus.png" style="margin-left: auto; margin-right: auto;"><img border="0" height="261" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTsMr3i0LTSrNM73In7_M10pk8ug_Mdsw8Wyp9_MdXxjKQ_1SSgvcERrCg0ksZOuQbKe7izNKHSQS6wRFl6UlxE6EkuzamYMm-bjo67PkJrFZDMp0VUtnxEscRZZxtFLuWnBgL2TkPEns/s400/bus.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Pas loin de Calais, sur la Cote d'Opale</td></tr>
</tbody></table>
<br />
Loin de moi l'idée de raconter ma vie - je préfère raconter celle des autres - mais cet été, je suis parti en voyage, sur la route, dans le Nord - dont la beauté des côtes n'a rien à envier à celles du pourtour méditerranéen, soit dit en passant.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNPfRdwLZ1ckahxHszh9VM8MaEGbXhXh5bEjQmesD1iB7tnrZ-Kdi9DBoPLQ6yRc2Whv6GSK414xnc1CXbSZK3poX98OwOEL_tYuqeNvor8aqVzZzeBw4_1aLEZelPrECu6BHehS8pfmU/s1600/panneau.png" style="margin-left: auto; margin-right: auto;"><img border="0" height="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNPfRdwLZ1ckahxHszh9VM8MaEGbXhXh5bEjQmesD1iB7tnrZ-Kdi9DBoPLQ6yRc2Whv6GSK414xnc1CXbSZK3poX98OwOEL_tYuqeNvor8aqVzZzeBw4_1aLEZelPrECu6BHehS8pfmU/s320/panneau.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Le tir au panneau n'est pratiqué qu'en Corse</td></tr>
</tbody></table>
<br />
Je suis un habitant du Sud de la France et les panneaux des communes que j'ai traversées dans le Nord accrochaient mon regard car leur phonétique était de toute évidence différente de celles de ma région. Souvent, la sonorité des communes, même quand elle a été couverte par un voile de métropolisation, laisse quand même transparaître quelques motifs bien spécifiques.<br />
<br />
De la même façon que François Guillem s'interroge sur la configuration spatiale des prénoms des Français, je me suis demandé de quelle manière il serait possible de faire apparaître la configuration des noms de commune en France.<br />
<br />
Tous les noms de commune sont différents, même si, rarement, certaines sont les mêmes. C'est pourquoi je me suis dit qu'il fallait me concentrer sur une partie du nom de la commune: la dernière syllabe du nom de chaque commune qui pouvait être commune à plusieurs. C'est souvent celle qui résonne le mieux et qui est la plus caractéristique de la région concernée.<br />
<br />
L'objectif était de voir, région par région, quelles étaient les dernières syllabes des noms de commune qui étaient les plus caractéristiques de chaque région, et par ce biais, leurs consonnances.<br />
<br />
Je m'attendais déjà à trouver en Bretagne, des syllabes se terminant en *EC, en Alsace en *EIN, en Corse en *CCIA, *CCIO<br />
<br />
Restait à savoir quel type de représentation choisir. Aucune représentation graphique mobilisant la forme, la couleur d'objets géométriques ne pouvait convenir. Seule une carte typographique pouvait répondre à ce besoin.<br />
<br />
Il faudrait alors s'atttaquer au texte et non aux styles objets géométriques. On pourrait ajuster, par exemple, la taille du texte en fonction de l'importance de cette syllabe pour une région donnée tout en faisant en sorte que les étiquettes ne se chevauchent pas.<br />
<br />
<br />
<b style="color: orange;">Conception</b><br />
<br />
Le fichier que j'ai utilisé est bien entendu GéoFLA (encore lui).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXxDhxTxSup-hnDbu6eL0riUhmulYpDBNo9c1Ul1nUzVFVn0evjOUoVT_sJbjgeyiBlFQjdot9yNM0wUgBNHGOREd9iT8Ca_1UsfyhBTfh-i2Nr0WxkzRoeak3wwVJKE_JhU7uF03TAjg/s1600/sortie.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXxDhxTxSup-hnDbu6eL0riUhmulYpDBNo9c1Ul1nUzVFVn0evjOUoVT_sJbjgeyiBlFQjdot9yNM0wUgBNHGOREd9iT8Ca_1UsfyhBTfh-i2Nr0WxkzRoeak3wwVJKE_JhU7uF03TAjg/s400/sortie.bmp" width="287" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Une syllabe <span class="st">est un son ou un groupe de sons qu'on prononce par une seule émission de voix. A défaut d'avoir à disposition une librairie phonétique, je me suis attaqué aux noms de communes à coup d'une expression régulière qui vaut ce qu'elle vaut: je ne suis</span> pas un expert de la régularisation (sauf des amis à qui je dois une bière)<span class="st">. Le résultat est ci-dessus.</span><br />
<br />
Je ne pouvais me contenter de mon comptage de syllabes par région car je retrouvais des syllabes fréquentes dans toutes les régions comme *ILLE. J'ai assorti le traitement d'une analyse en composantes factorielles afin de voir, pour chaque région, quelles étaient les syllabes les plus représentatives. Par la suie, j'ai choisi de me concentrer uniquement sur les 30 premières les plus caractéristiques.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi_jQr-12xACdiYyeikSw0EHdcIXFHhc0FfzEZD7DvLuB6O1UNaYkOZw8NdfMFQiWZKvufnzWuWaoXfF_q72izmwg1YJ9Ld3Bpk7p8sLzc0b7V3YSIWuMGbNCOh4N_RIT5A3BfZRPWaLc/s1600/types_orga.jpeg" style="margin-left: auto; margin-right: auto;"><img border="0" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi_jQr-12xACdiYyeikSw0EHdcIXFHhc0FfzEZD7DvLuB6O1UNaYkOZw8NdfMFQiWZKvufnzWuWaoXfF_q72izmwg1YJ9Ld3Bpk7p8sLzc0b7V3YSIWuMGbNCOh4N_RIT5A3BfZRPWaLc/s640/types_orga.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Différentes dispositions de point possibles</td></tr>
</tbody></table>
<br />
Une fois cela fait, j'ai créé un semis de points au niveau de chaque polygone dont la répartition est intermédiaire entre le régulier et l'aléatoire. Cette répartition est appelée "non-alignée". Ce semis de points servira à positionner les étiquettes. Par conséquent, ces dernières étiquettes ne seront pas positionnées en fonction de la localisation absolue de communes leur correspondant, mais en fonction de leur région d'appartenance.<br />
<br />
Ensuite, j'ai affecté une taille variable, selon 6 classes, à mes étiquettes en fonction de leur poids (selon la classification de Jenks qui maximise la variablité inter-classes et minimise l'intra)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-Z_NhfbNja8Bywm4Jkw_c3xUq72C07l8UjzrzYbzB2LSyq-6jUIRPaamOrARMnO3GUZclrWLmJKpJM9nHbRReBT27B1FYBsoDO7rEdmphZc9oJzdox0h_dT90fWpq0JfsfYImlBMJNxU/s1600/region_syllabes_memecouleur.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-Z_NhfbNja8Bywm4Jkw_c3xUq72C07l8UjzrzYbzB2LSyq-6jUIRPaamOrARMnO3GUZclrWLmJKpJM9nHbRReBT27B1FYBsoDO7rEdmphZc9oJzdox0h_dT90fWpq0JfsfYImlBMJNxU/s640/region_syllabes_memecouleur.png" width="640" /></a></div>
<br />
J'ai affecté une couleur différente aux libellés selon la région à laquelle ils appartenaient.<br />
<br />
Afin d'avoir un rendu optimal de toutes mes étiquettes, j'ai choisi une solution de nuage de mots (word cloud). Le word cloud permet de faire en sorte que les étiquettes s'emboîtent les unes dans les autres.<br />
<br />
<br />
<b style="color: orange;">Le rendu</b><br />
<b style="color: orange;"><br /></b>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.flickr.com/photos/10519370@N04/7993485033/sizes/o/in/photostream/" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbPts7utfRRA3si0KMuMgNRlfSmlQUQySxWO58hny43kp0mEPhLVYNIF2mQt9aMuU0rBrHYxPgeXMRhsNMmbMtj-qhtDXw0B60dvjPEktnBZ4qyY16oPBI4fnj5nAj_Vx_plK2w8AftJw/s640/out_gimp3.png" width="585" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Carte des noms des commune (cliquer pour voir en grand)</td></tr>
</tbody></table>
<br />
Certes, cette carte n'est pas aussi ambitieuse que celles présentées dans les liens précédents mais il s'agit d'un bon début!<br />
<br />
Parfois, vous pourrez voir sur la carte quelques artefacts: des libellés se balladent dans une autre région. Le choix des tailles de police n'étant pas optimal, lorsque tout l'espace est saturé, les boîtes de texte ne s'emboîtent plus et essaient de conquérir un espace libre.<br />
<br />
On pourrait appliquer cette technique à bien d'autres choses: les prénoms des français, par exemple, à l'image de ce qui a été réalisé sur la carte du National Geographic (USA surnames).<br />
<br />
<br />
<b style="color: orange;">Le code</b><br />
<br />
Et bien sûr, le code!
<br />
<br />
<script src="https://gist.github.com/3734388.js?file=city_names_wordcloud.R"></script><br />
<br /></div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com1tag:blogger.com,1999:blog-9055497882207462476.post-14572619211904240422012-08-15T04:10:00.000-07:002012-09-30T23:20:44.355-07:00[Sextante Plugin] An R script for Neighborhood Detection<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRHLzjihHR4FkTwUwp82RX10JHUB-Na702qfQsd0H-XiUwJ71JRg_lP5d4Cs-Zkrt2pRCUQcDGQwpMSDUM3eo84WORp_QdpK7b0hTtgMX8t1hYjFokl_TU2vW9Ldp_xam01aN99KT4qfo/s1600/19.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<div style="color: orange;">
<div style="text-align: right;">
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg7kgbQFQ5jG7lngER689xrojddapArQHq7UQGb9gXi-W6iJswcMxCpWP_qudNXW9vRHqqV9mXkQ_wiQ36m8-9F6eNYJXSzLAYIy5ii3Nd7-o8MbgkqpPI3MrAbs9z3KnmmskhKedxgOs/s1600/12.gif" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="170" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg7kgbQFQ5jG7lngER689xrojddapArQHq7UQGb9gXi-W6iJswcMxCpWP_qudNXW9vRHqqV9mXkQ_wiQ36m8-9F6eNYJXSzLAYIy5ii3Nd7-o8MbgkqpPI3MrAbs9z3KnmmskhKedxgOs/s200/12.gif" width="200" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Des bâtiments regroupés en bloc à Paris</td></tr>
</tbody></table>
<span style="background-color: #f3f3f3; color: black;">Artice in English</span></div>
<br />
<span style="color: black;"><i><b>[Plugin Sextante] Un script R pour détecter les voisinage</b></i>s : Cet article explique comment réaliser <a href="https://docs.google.com/open?id=0B2ZYzwKbiu3JR2pkLVBIVnJyb1k" target="_blank">un petit script R</a> via le plugin Sextante pour QGIS afin d'établir des relations de voisinage entre objets en fonction de la distance qui les sépare. Il comporte une petite introduction sur l'écosystème QGIS, sur R aussi. Et puis bien sûr, des détails sur l'écriture d'un script R pour le plugin Sextante GIS Plugin.<b><br /></b></span><br />
<span style="color: black;"><b><br /></b></span></div>
<div style="color: black;">
<br />
<br />
<a name='more'></a><b>Content</b>:</div>
<ul>
<li>An opensource spatial constellation </li>
<ul>
<li>R</li>
<li>QGIS as a solar planet</li>
<li>Sextante GIS plugin as a glue</li>
<li>R and QGIS </li>
</ul>
</ul>
<ul>
<li>Performing a neighborhood analysis with Sextante plugin </li>
<ul>
<li>The R example scripts</li>
<li>Neighborhood by distance: my R script</li>
<li>Writing an R script</li>
<li>The complete Sextante R script </li>
</ul>
</ul>
<ul>
<li>Usage in QGIS</li>
<ul>
<li> Quiet places where to sleep/live in Paris</li>
<li>Styling and visualizing</li>
<li>Statistics</li>
<li>Convex hulls</li>
</ul>
</ul>
<div style="color: orange;">
<br />
<span style="color: black;">Download the R script directly <a href="https://docs.google.com/open?id=0B2ZYzwKbiu3JR2pkLVBIVnJyb1k" target="_blank">here</a>. </span><b><br /></b></div>
<br />
<div style="color: orange;">
</div>
<span style="color: orange; font-size: large;"><u><b>An opensource constellation</b></u></span><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://upload.wikimedia.org/wikipedia/commons/c/c2/Solar_sys.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="250" src="http://upload.wikimedia.org/wikipedia/commons/c/c2/Solar_sys.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">http://commons.wikimedia.org/wiki/File:Solar_sys.jpg</td></tr>
</tbody></table>
<br />
<div style="color: orange;">
<b>R</b></div>
<br />
<a href="http://www.r-project.org/" target="_blank">R</a> is a statistical language from which a huge number of libraries, representing a multicoloured palette of domains, have proliferated, from finance to ecology, from spatial to morphometry.<br />
<br />
Its popularity is increasing very fast. Even <a href="http://www.nytimes.com/2009/01/07/technology/business-computing/07program.html?_r=1" target="_blank">the New York Times</a> wrote about it. Also, an article describes <a href="http://blog.revolutionanalytics.com/2011/08/google-r-effective-ads.htm" target="_blank">how it is used at google</a>.<br />
<br />
More and more companies search for data scientists that master R, besides SAS, the proprietary equivalent tool.<br />
<br />
In the spatial domain, there are some functions that you'll never find in any opensource GIS software, be it GRASS or Sextante.<br />
<br />
In <a href="http://cran.r-project.org/web/views/Spatial.html" target="_blank">this spatial R page</a>, you might discover some tasks you've never heard of in the geospatial world, like spatial modeling, point patterns and small area estimations.<br />
<br />
<br />
<b style="color: orange;">QGIS as a solar planet</b><br />
<br />
More and more, QGIS tends to integrate famous tools. The first one was GRASS, then there was R, Sextante GIS, recently there was the Orfeo Toolbox for Imagery and Remote Sensing.<br />
<br />
All of this constitutes an opensource spatial galaxy/ecosystem in which every planet (here, software) develops itself in contact with other planets, also stars (the technologies that gain popularity like Mapnik, Leaflet).<br />
<br />
<br />
<div style="color: orange;">
<b>Sextante GIS in QGIS as a glue</b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSxetGyYU0uCf2mUblqq4EitiMlEQkOH6xloRjVtvoDBGzOkEyUSxr_nzNqksGgllwO9v-VDCG5VDv9pxSqZFy0EpZZ5KDV69EreVzgnYZdUF7kVlpTbI84ygR7cX6AiUrWaA5PdjNuSga/s1600-r/sextante_header.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSxetGyYU0uCf2mUblqq4EitiMlEQkOH6xloRjVtvoDBGzOkEyUSxr_nzNqksGgllwO9v-VDCG5VDv9pxSqZFy0EpZZ5KDV69EreVzgnYZdUF7kVlpTbI84ygR7cX6AiUrWaA5PdjNuSga/s1600-r/sextante_header.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="88" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSxetGyYU0uCf2mUblqq4EitiMlEQkOH6xloRjVtvoDBGzOkEyUSxr_nzNqksGgllwO9v-VDCG5VDv9pxSqZFy0EpZZ5KDV69EreVzgnYZdUF7kVlpTbI84ygR7cX6AiUrWaA5PdjNuSga/s1600-r/sextante_header.png" width="320" /></a><br />
<br />
Initially, <a href="http://sextantegis.blogspot.be/" target="_blank">Sextante GIS</a> is a geospatial library.<br />
Then, it became a plugin for QGIS, developed by Victor Olaya. It not only included Sextante functionalities but also functions from Orfeo Toolbox, R, GDAL, GRASS,...<br />
<br />
The goal of this plugin is to indifferently execute functions from different libraries in a graphical environment since not everybody is familiar with command lines.<br />
<br />
Also, the Sextante QGIS Plugin integrates a modeler in which you can chain functions and make QGIS a kind of automated factory for spatial tasks. Remember <a href="http://grass.osgeo.org/gdp/html_grass64/wxGUI.Modeler.html" target="_blank">GRASS also has a modeler</a>.<br />
<br />
I think that with the improvement of his Sextante modeler, QGIS could become a very powerful <a href="http://en.wikipedia.org/wiki/Spatial_ETL" target="_blank">spatial ETL </a>and could compete with Spatial Data Integrator/Talend Open Studio, GeoKettle or FME (when it deals with spatial treatments).<br />
<br />
<br />
<b><span style="color: orange;">R and QGIS</span></b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcbn3T5dPlMraGxeHyWpZLe8UDpdX-dnZvx0n7oDW8ejQFwG1bOhkyjLGZFACAYSvW4TZW6HauGhKb4dJyP8H8IntdueBlr8J7JJsHZ7N80nhDvBTfC_t_oI2g5kZmF8CJ2Tx8na7H89M/s1600/rqgis.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="101" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcbn3T5dPlMraGxeHyWpZLe8UDpdX-dnZvx0n7oDW8ejQFwG1bOhkyjLGZFACAYSvW4TZW6HauGhKb4dJyP8H8IntdueBlr8J7JJsHZ7N80nhDvBTfC_t_oI2g5kZmF8CJ2Tx8na7H89M/s200/rqgis.jpg" width="200" /></a></div>
<br />
There are many plugins that use the R library: manageR by Carson Farmer, spqr by Barry Rowlingson, SDA4PP (Spatial Data analysis For Point Patterns, Home Range Estimation <br />
<b><br /></b>
- <a href="http://www.ftools.ca/manageR/" target="_blank">manageR</a> is an R editor inside QGIS. Knowing R is a prerequisite for using this plugin.<br />
<br />
- <a href="http://www.maths.lancs.ac.uk/%7Erowlings/Software/Spqr/" target="_blank">spqr </a>produces graphics for stat visualizations .<br />
<br />
- SDA4PP is a suite of functions for the analysis of point patterns: are the points clustered, seggregated? <br />
<b><br /></b>
I think that the most interesting R plugins for QGIs are those that guide the user through a graphical interface and perform complex R tasks behind.<b><br /></b><br />
<br />
<br />
<b style="color: orange;">R in Sextante QGIS plugin</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSFc1Jt9yi6ZVd22kF3XbaGEKtc7un7sqRooUesYDKRsMH5RE90bDZNdvS7zrT7lnc3SUIpv7V9VuMfE5xVzqDXQKMK3VhDVV6S3O3I1h7PjJ_vkS9Q7rBmgSGWLtseO7PJf_Rrpf9vbs/s1600/15.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSFc1Jt9yi6ZVd22kF3XbaGEKtc7un7sqRooUesYDKRsMH5RE90bDZNdvS7zrT7lnc3SUIpv7V9VuMfE5xVzqDXQKMK3VhDVV6S3O3I1h7PjJ_vkS9Q7rBmgSGWLtseO7PJf_Rrpf9vbs/s400/15.gif" width="400" /></a></div>
<br />
When you install the Sextante GIS plugin, you must activate the R scripts to get them available in the Sextante dock<br />
<br />
- Also, you have to mention where R is installed.<br />
<br />
- I preferred to move all the R scripts that initially were in C:\Documents and Settings\[username]\.qgis\python\plugins\sextante\r\scripts to C:/R/QGIS_SEXTANTE to make them more
accessible. I changed the R scripts folder in the configuration dialog as you can see in the image above.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc477KKcS8_WOiXsCxU8lvM5AvTv71guAs2zNIS_1qt-VPvonv15y-n8MUFwZP0-F_8J1ZbKedtiT0WsTbGhs7h2tMCu9QVXNWO_B00QGduNENR3zvpIAA7GnHFhoVM6P0MQAM2KU1MfI/s1600/16.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc477KKcS8_WOiXsCxU8lvM5AvTv71guAs2zNIS_1qt-VPvonv15y-n8MUFwZP0-F_8J1ZbKedtiT0WsTbGhs7h2tMCu9QVXNWO_B00QGduNENR3zvpIAA7GnHFhoVM6P0MQAM2KU1MfI/s400/16.gif" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The Sextante R Scripts</td></tr>
</tbody></table>
<br />
If you don't know anything about R and if you want to use an R script but you don't have the approriate package to use it, all you have to know is how to install this package. It is very simple. I recommend you <a href="http://rstudio.org/" target="_blank">RStudio</a> for this (if a library has not been installed in your standard R, it won't be available in Sextante QGIS R scripts)<br />
<br />
Using an R script doesn't require any knowledge in R programming but it's preferrable to understand how it is made, and to see which function it uses. You can refer yourself to the documentation to get some details, by using <a href="http://www.rseek.org/" target="_blank">R-Seek</a>. Be studious: some functions sometimes require some theoretical knowledge <a href="http://www.geography.hunter.cuny.edu/%7Ejochen/GTECH361/lectures/lecture11/concepts/Kriging.htm" target="_blank">"that could lead either to years of therapy, or to your Ph.D"</a>. <br />
<br />
<br />
<br />
<div style="color: orange;">
<span style="font-size: large;"><u><b>Performing a neighborhood analysis with Sextante plugin </b></u></span></div>
<br />
<div style="color: orange;">
<b>The R example scripts</b></div>
<br />
There a already 9 R scripts in the package as you can see in the image above. The system of these scripts are input-output systems where the inputs are always spatial data and where outputs can either be spatial data, plots (images), or console outputs.<br />
<br />
- With the <b>Ripley Rason script</b>, you can create some envelopes that are a bit like convex hulls but stick more to the group of elements.<br />
<br />
- You can create create either <b>regular, either random points</b> based on a polygon (generally, we use a grid)<br />
<br />
- You can analyze the clustering of points using the <b>F, G, K Functions scripts</b><br />
<br />
- You can check whether you values are random - that means following a normal distribution - with the <b>Kolgomorov-Smirnov </b>normality test script<br />
<br />
- You can make kind of same analysis but with <b>spatial quadrats</b>: consider a study zone with points. You divide this zone into a certain number of squares (quadrats). You count the points inside each square. Finally, you make a test to see if your points are randomly located (it's called the null hypothesis of Complete Spatial Randomness).<br />
<br />
- There is an R script that makes a <b>raster histogram</b>. It illustrates that you can have rasters as inputs, not only vectors.<br />
<br />
<br />
<br />
<b style="color: orange;">Neighborhood by distance: my R script</b><br />
<br />
As you can see, the R scripts mainly focus on point patterns. I wanted to implement an R script that I had already written, but in an R environment, that focused on areas.<br />
<br />
The goal of this R script is to specify a distance below which some polygons (for instance, buildings) are considered neighbors. Once it finds the neighborhood relationships, it counts the neighbors and affects each building to the group of neighbors it belongs to.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmx8aGKr4dAMwmr-5Fx8h7G37no6iPunmfG_5yhp-9b6Y0MPrfoC4cE1zuygKkUH0kMnNWTbSvbAWoqX85ya51hERjogSabEMyg51ZVmfOL35awHGjp-IU59N3TLPULArZNHZ7_JrIk9M/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="285" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmx8aGKr4dAMwmr-5Fx8h7G37no6iPunmfG_5yhp-9b6Y0MPrfoC4cE1zuygKkUH0kMnNWTbSvbAWoqX85ya51hERjogSabEMyg51ZVmfOL35awHGjp-IU59N3TLPULArZNHZ7_JrIk9M/s400/4.png" width="400" /></a></div>
<br />
<br />
The output of this script is the same layer as the base one but enriched with two more attributes: neighbors count and neighbor group.<br />
<br />
This script can be useful to determine the structure of the habitat and detect the buildings that are isolated or highly grouped based on a mimimum distance threshold.<br />
<br />
<a href="http://cran.r-project.org/web/packages/spdep/index.html" target="_blank">Here</a>, you'll find a complete description of the spdep package.<br />
<br />
Here is the script, in R language:<br />
<br />
<script src="https://gist.github.com/3315103.js?file=neighbor.R"></script><br />
<br />
<br />
<div style="color: orange;">
<b>Writing an R script</b></div>
<br />
The goal was to transform this R script into a Sextante-QGIS R scripts.<br />
<br />
If you click on "create a new R script", an edition window opens and you can have an assistant through the "edit script help" button. Unfortunately, I didn't understand how this script help worked. So, I inspired myself from the example scripts.<br />
<br />
To create a script, create a new file, in my case, neighborhood_by_distance.rsx and edit it.<br />
<br />
An R script is structured in two parts:<br />
- the <b>configuration part</b> where you set the input, output, options.<br />
- the <b>code part </b>where you use the variables set in the configuration part inside a standard R script.<br />
<br />
<br />
<div style="color: orange;">
<i><b>The configuration part</b></i></div>
<br />
<div style="color: orange;">
Group</div>
<div style="color: orange;">
<br /></div>
Each script belongs to a group of scripts. It's the group key, for instance,<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="background-color: #fff2cc;">##[datagistips]=group</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<br /></div>
means that the script belongs to the "datagistips" group. If the group doesn't exist, it will automatically be created.<br />
<br />
<span style="color: orange;">Input</span><br />
<br />
The inputs are either vector, either raster. I don't think you can mention you'd like a certain type of features: points, lines or polygons (maybe an improvement to be done as some analysises can only be done on a certain type of features?)<br />
<br />
For vectors, you write:<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="background-color: #fff2cc;">##polygons=vector</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<br /></div>
polygons will be the label in the graphical window<br />
<br />
For rasters:<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="background-color: #fff2cc;">##layer = raster</span></div>
<br />
<div style="color: orange;">
Options</div>
<div style="color: orange;">
<br /></div>
In options, the user can indicate a numeric value or a string value.<br />
<br />
For the numeric value<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="background-color: #fff2cc;">##distance=number 100</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<br /></div>
Here, the label will be distance and the default value is set to 100.<br />
When the user will specify the value, he will type it manually or choose it from the different layer statistics <br />
<br />
If the value is character, the user will have to type it.<br />
<span style="background-color: #fff2cc;"> <span style="font-family: "Courier New",Courier,monospace;">##title=string France</span></span><br />
<br />
Here, the label will be title and the default value is set to France<br />
<br />
<div style="color: orange;">
Fields</div>
<br />
One very interesting thing is that you can use a field in a script. In the case of the Kolgomorov-Smirnov example script, you choose the numeric field from which to test the normality. <br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="background-color: #fff2cc;">##field=field layer</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<br /></div>
Then, in a script<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="background-color: #fff2cc;">>lillie.test(layer[[field]]) </span></div>
will integrate the field variable into the script<br />
<br />
<div style="color: orange;">
Outputs</div>
<div style="color: orange;">
<br /></div>
For spatial data outputs, simply write<br />
<span style="background-color: #fff2cc; font-family: "Courier New",Courier,monospace;">##output=output vector</span><br />
<br />
Graphical outputs and console outputs will both be in HTML format<br />
<br />
For graphical plots outputs, you must mention the tag<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="background-color: #fff2cc;">##showplots</span></div>
(you could imagine producing some lovely plots with ggplot2)<br />
<br />
For console output, you must precede the command by <b>></b><br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="background-color: #fff2cc;">>lillie.test(layer[[field]]) </span></div>
<br />
<br />
<div style="color: orange;">
<b>The complete Sextante R script</b><br />
<br />
<div style="color: black;">
Below is the final R script. You can also download it <a href="https://docs.google.com/open?id=0B2ZYzwKbiu3JR2pkLVBIVnJyb1k" target="_blank">here</a>.<br />
<br />
As you can see, you can instantly port your R
code to a graphical environment so that every QGIS user, even a beginner, can use your
process. Also, it's easier than developing a python QGIS plugin.<br />
<script src="https://gist.github.com/3315054.js?file=gistfile1.txt"></script>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtueDFCQPxHjhUhGmDZ5ZFSUllp7QBjGl8wtoPxCd066jKB_tr3nAf4OLUtlzUUVRMr8Dp_7x_RzpdPY01QlAeFkYJD3IEp_SDaRtKlbVk6Bi2_u6FCTTXDHrKDNDATs07PwGJ4w0ObSk/s1600/3.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtueDFCQPxHjhUhGmDZ5ZFSUllp7QBjGl8wtoPxCd066jKB_tr3nAf4OLUtlzUUVRMr8Dp_7x_RzpdPY01QlAeFkYJD3IEp_SDaRtKlbVk6Bi2_u6FCTTXDHrKDNDATs07PwGJ4w0ObSk/s400/3.gif" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The plugin then appears in the Sextante Toolbox</td></tr>
</tbody></table>
<b> </b></div>
<br />
<div style="color: orange;">
<u><span style="font-size: large;"><b>Usage example in QGIS</b></span></u></div>
<br />
<div style="color: orange;">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://upload.wikimedia.org/wikipedia/commons/1/1d/Paris_sunset.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="266" src="http://upload.wikimedia.org/wikipedia/commons/1/1d/Paris_sunset.JPG" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><a href="http://commons.wikimedia.org/wiki/File:Paris_sunset.JPG">http://commons.wikimedia.org/wiki/File:Paris_sunset.JPG</a>
</td></tr>
</tbody></table>
<br />
<br />
Quiet places where to sleep/live of Paris</div>
<br />
<span style="color: black;">Here, I executed the script on an extract of buildings in the 1st district of Paris that I downloaded from the</span> <a href="http://download.geofabrik.de/" target="_blank">Geofabrik OpenStreetMap data repository</a><br />
<div style="color: black;">
<br /></div>
<div style="color: black;">
You could use it to determine which buildings are the most isolated, where you would probably sleep one night or live, far from the busy, crowdy life of the City of Lights.</div>
<div style="color: black;">
<br /></div>
<div style="color: black;">
The distance that I chose was 15 meters. In such a big city like Paris, that's quite a lot.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7LPH3nr8Fd_WO-4jvHgcZxXC_e106jPx6AYU0h6mrALxnk9Y1l3KtE3e1JLcp-3PfE54QaiQ360H0sHOndEfQVAuEU4KmPAanAYMJzSglgvrP9Bu8whG8kKmQgbyl1eYMrKWJQLDIZaA/s1600/21.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="293" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7LPH3nr8Fd_WO-4jvHgcZxXC_e106jPx6AYU0h6mrALxnk9Y1l3KtE3e1JLcp-3PfE54QaiQ360H0sHOndEfQVAuEU4KmPAanAYMJzSglgvrP9Bu8whG8kKmQgbyl1eYMrKWJQLDIZaA/s400/21.gif" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The R script in action</td></tr>
</tbody></table>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHy1cjOcMuUXnZfRAEUFiWvoKDZZPp1C35PkbDXxs8I5gaLzWmqPLYCbUExII3GpJE_Ji4jdZfiQmlyArqItX6wqk1VvJ9xvGq_c_cf5s2TevJ31c3O0yO1GRATbNrHeLCehmAvMav4Jc/s1600/9.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<span style="color: orange;">Styling and visualizing</span><br />
<br />
<div style="color: black;">
Once I had my neighbors layer, I could style it differently depending on the neighbors counts or the group it belonged to..</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdGuXvx0MXq5fxLA4Q8315BE-epCWGxyEpDbLMCHXCaChBmzDIvhnhqZW7kC7QoKDwQ_23Td6DkdYZs88CxR3Vz9dv5_2HonmhcyCHauxSmi3LBjbAvOq0eogkxxhoCzvUnktvziqPavg/s1600/20.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="556" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdGuXvx0MXq5fxLA4Q8315BE-epCWGxyEpDbLMCHXCaChBmzDIvhnhqZW7kC7QoKDwQ_23Td6DkdYZs88CxR3Vz9dv5_2HonmhcyCHauxSmi3LBjbAvOq0eogkxxhoCzvUnktvziqPavg/s640/20.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Clustered and isolated buildings on top of OSM data (with OpenLayers plugin)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div style="color: orange;">
Statistics</div>
<br />
<div style="color: black;">
With the standard statistics tools incorporated in QGIS, you can analyze the spatial structure.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0EMh5A_8JKe18gUGfS3WYMZ18Zf1tR46OdCQtk_a3mUWwe_yky91-85-85aChpRAztD00uyIalu0edh3kITHjkb7GZ22JQI6qUmU2AwAZR9C52o-C9mJCscaZIhBt3AmbkUei86ga4U8/s1600/10.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0EMh5A_8JKe18gUGfS3WYMZ18Zf1tR46OdCQtk_a3mUWwe_yky91-85-85aChpRAztD00uyIalu0edh3kITHjkb7GZ22JQI6qUmU2AwAZR9C52o-C9mJCscaZIhBt3AmbkUei86ga4U8/s400/10.gif" width="323" /></a></div>
<br />
<div style="color: black;">
The results mention that there 24 groups of neighbors. The biggest group contains 23 buildings. Half of the neighbors contain between 0 and 7 neighbors.</div>
<div style="color: black;">
<br /></div>
<div style="color: black;">
You can also produce histograms of these values with the Statist plugin and see the distribution of counts for the neighbor groups</div>
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbQ234Il140LrEzxhL659Jfjb2NrJQ3CSWh5DtmMa7AyDxL2hoiRP98RxS7jE9oaaW4ES1hb1MiSM3lE5OTpSEGAZgppz0xsc0tqQfv2n0SesJbckxRR1DATSuOl-A3qPTsZ7aDTdCsN8/s1600/11.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="370" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbQ234Il140LrEzxhL659Jfjb2NrJQ3CSWh5DtmMa7AyDxL2hoiRP98RxS7jE9oaaW4ES1hb1MiSM3lE5OTpSEGAZgppz0xsc0tqQfv2n0SesJbckxRR1DATSuOl-A3qPTsZ7aDTdCsN8/s640/11.gif" width="640" /></a> <br />
<br />
<div style="color: black;">
By using the request functionnality, I could locate buildings that where relatively isolated.</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRHLzjihHR4FkTwUwp82RX10JHUB-Na702qfQsd0H-XiUwJ71JRg_lP5d4Cs-Zkrt2pRCUQcDGQwpMSDUM3eo84WORp_QdpK7b0hTtgMX8t1hYjFokl_TU2vW9Ldp_xam01aN99KT4qfo/s1600/19.png" style="margin-left: auto; margin-right: auto;"><img border="0" height="328" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRHLzjihHR4FkTwUwp82RX10JHUB-Na702qfQsd0H-XiUwJ71JRg_lP5d4Cs-Zkrt2pRCUQcDGQwpMSDUM3eo84WORp_QdpK7b0hTtgMX8t1hYjFokl_TU2vW9Ldp_xam01aN99KT4qfo/s640/19.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Buildings with less than 3 neighbors (distance of 15m) on top of Bing Aerial Imagery</td></tr>
</tbody></table>
<br />
<div style="color: orange;">
Convex hulls</div>
<br />
<div style="color: black;">
Finally, why not creating convex hulls to visualize the neighborhood groups and put some OSM data behind to see how it looks?</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJFUnqVlxWMkOa2ptZF7MePecBcyfABIdjLaQET4Xd5vF-cuWm8GQKN86wS3QVic5SRmwS6ZErPRS82WSlT9j3kZbENq4nz6gRn4N0KjwmxnQr-3oLCESpQwulg7rJA83LpoKFuBFeq8E/s1600/8.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="206" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJFUnqVlxWMkOa2ptZF7MePecBcyfABIdjLaQET4Xd5vF-cuWm8GQKN86wS3QVic5SRmwS6ZErPRS82WSlT9j3kZbENq4nz6gRn4N0KjwmxnQr-3oLCESpQwulg7rJA83LpoKFuBFeq8E/s320/8.gif" width="320" /></a></div>
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVvkmcJb9JQC_0yWzbFlZs1W3vR9bHxlR7H9wjBdRw_KyUQ1VewbkncDPfyila2mWvseRkuf9j8KUC6eaT5GZasHc-C52ZABN0t8HWnAaa6JmTB_zM8eO7TilNpEdNF7yj-8FSjPatV8M/s1600/9.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="556" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVvkmcJb9JQC_0yWzbFlZs1W3vR9bHxlR7H9wjBdRw_KyUQ1VewbkncDPfyila2mWvseRkuf9j8KUC6eaT5GZasHc-C52ZABN0t8HWnAaa6JmTB_zM8eO7TilNpEdNF7yj-8FSjPatV8M/s640/9.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The output data on top of OpenStreetMap data (15 meters threshold)</td></tr>
</tbody></table>
<br />
<div style="color: black;">
When on top of OSM data, you can easily visualize the buildings groups. Remember that it all depends on the distance thereshold you used. With a 5m threshold, you get this:</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg7kgbQFQ5jG7lngER689xrojddapArQHq7UQGb9gXi-W6iJswcMxCpWP_qudNXW9vRHqqV9mXkQ_wiQ36m8-9F6eNYJXSzLAYIy5ii3Nd7-o8MbgkqpPI3MrAbs9z3KnmmskhKedxgOs/s1600/12.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="544" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg7kgbQFQ5jG7lngER689xrojddapArQHq7UQGb9gXi-W6iJswcMxCpWP_qudNXW9vRHqqV9mXkQ_wiQ36m8-9F6eNYJXSzLAYIy5ii3Nd7-o8MbgkqpPI3MrAbs9z3KnmmskhKedxgOs/s640/12.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The same but with a 5 meters threshold (nicer than with a 15m threshold, isn't it?)</td></tr>
</tbody></table>
<br />
<span style="color: black;">These spatial groups could probably reflect the different residences that exist in this place. They could be useful to plan a more detailed OSM investigation and mapping on the ground (to map residences in OpenstreetMap, use</span><a href="http://wiki.openstreetmap.org/wiki/Tag:landuse%3Dresidential" target="_blank"> landuse=residential</a>, <span style="color: black;">name=[residence name], or</span> <a href="http://wiki.openstreetmap.org/wiki/Relations/Proposed/Site" target="_blank">a relation of type site</a><span style="color: black;">)</span><br />
<br />
<span style="color: black;">Also, you could use these blocks as a base layer for some aggregated statistics: number of buildings, area, perimeter, lacunarity, fractal dimension, and so forth.. </span></div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com6tag:blogger.com,1999:blog-9055497882207462476.post-42564226927500414682012-07-08T23:30:00.001-07:002012-08-27T00:00:46.421-07:00Isarithmic Map of French Votes: Why and How-to<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.blogger.com/blogger.g?blogID=9055497882207462476#" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1O27lAU9uY5OPIJU7tEhN4pjoA0AY1_k0T1NU8oT1y6C2J_sXyX5KzG5fNjGPqKi-bN7STQXXUwn9t89L1jpziIR9rSAa_APl6tNfWj_J9r29p6lC9z-nLy89UjSQ-xyLmP5TxB4X-F4/s200/ISA_CHORO.png" width="200" /></a></div>
<br />
<div style="text-align: right;">
<span style="background-color: #d0e0e3; color: black;">Article in English </span></div>
<br />
<i><b>Cartes isarithmiques: pourquoi les utiliser et comment les réaliser?</b></i> Cet article explique l'intérêt des cartes isarithmiques, pourquoi elles réussissent là où d'autres types de visualisation échouent. En réalité, la création de cartes isarithmiques est un procédé original dans le domaine de la géomatique, de la cartographie en général, se basant sur des masques continus et non binaires. L'article explique les principes techniques de telles réalisations et délivre le code à la fin du post.<br />
<br />
<br />
<br />
<br />
<br />
<a name='more'></a><br />
<a href="http://datagistips.blogspot.fr/2012/05/resultats-du-second-tour-choroplethe.html" target="_blank">Previously</a>, we learnt how to create a simple choropeth for vote results in France:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK2KjU1egsKbhFUAjhFOECQKEeggG8XJFjOk0dw-w54vac7oZF4YOOzP_j4bWUQfF74PAxUqfAfPrYLEGkauVtpn8bha4-H4j33u58wuxqixHfRsBQpJ57aazWx08LebFCakGWrRkGaCg/s1600/Rplot01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="196" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK2KjU1egsKbhFUAjhFOECQKEeggG8XJFjOk0dw-w54vac7oZF4YOOzP_j4bWUQfF74PAxUqfAfPrYLEGkauVtpn8bha4-H4j33u58wuxqixHfRsBQpJ57aazWx08LebFCakGWrRkGaCg/s200/Rplot01.png" width="200" /></a></div>
<br />
But is percentage enough to represent the election results? Here, we don't take population in terms of number of inhabitants or density into account, although population is an important variable. The aim of this article is to study a kind of map called isarithmic map. It combines the visualization of two variables in a specific and compelling way.<br />
<br />
<u>Content:</u><br />
<br />
<ul>
<li>Analysis of different visualization combinations</li>
<li>Isarithmic maps</li>
<li>The R code: technical explanations</li>
<li>Complete code on github </li>
</ul>
<br />
<span style="color: orange;"><b>Analysis of different visualization combinations</b></span><br />
<span style="color: orange;"><b><br /></b></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhURilQ_jWqIuQ3obCg-TNQw0GapHhZSRKfYQHhxgV8o5DViD_wiL6ixqjBxP_EJ8HyVl10f508WW8oqD6Blb-EgntPq7zTpWQJUsMLA0tx4rIDq4qUeOduiDfxOHZF7YZj73MfpFdiUh0/s1600/datasource.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="176" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhURilQ_jWqIuQ3obCg-TNQw0GapHhZSRKfYQHhxgV8o5DViD_wiL6ixqjBxP_EJ8HyVl10f508WW8oqD6Blb-EgntPq7zTpWQJUsMLA0tx4rIDq4qUeOduiDfxOHZF7YZj73MfpFdiUh0/s320/datasource.jpg" width="320" /></a></div>
In our case, we have one polygonal data and it contains both informations we're interested in.<br />
<br />
<ul>
<li>Column VOTES that we got from integrating a csv file found on data publica </li>
<li>and one column POPULATION that we get from the original source GEOFLA data.</li>
</ul>
<br />
Percentage of votes and population are two continuous numeric values. If we had one categorical data like "left", "right", it might have been easier to make a map: population represented as gradually colored polygons and blue/red dots above representing the dominant party.<br />
<br />
In our case, we don't want to alterate the data and transform numeric data into categorical data. Also, we want to keep votes data as polygon data. Consequently, for the visualization purpose, we can consider these different options are available (more may be possible):<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiX_W_Y8x0ZjQ8Oqn8uETNpWWEhC3SPzT800K4mMn3sDNbKCL0nnY42GiPURlpE5lfdaKUKByMLXjzS3dcGcRW4bDVReB_1kq_f2zcmAQHfTX9z2q9I1VdXStzQdmBRpACyaFEqV2eP_E/s1600/isachoro.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiX_W_Y8x0ZjQ8Oqn8uETNpWWEhC3SPzT800K4mMn3sDNbKCL0nnY42GiPURlpE5lfdaKUKByMLXjzS3dcGcRW4bDVReB_1kq_f2zcmAQHfTX9z2q9I1VdXStzQdmBRpACyaFEqV2eP_E/s400/isachoro.jpg" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Polygon + XX visualization types</td></tr>
</tbody></table>
<ul>
<li>a <i>simple overlay</i> is not relevant. We don't know if the brightness comes from population or votes values.</li>
<li>a <i>combination of dots and polygon</i> is better but mixing different shapes might be a little complex visually. Furthermore, in the case the city is small, the dot could overlay the polygon. Putting two many types of colors aside can be painful for your brain and they finally can be difficult to evaluate.</li>
<li><i>non contiguous cartograms </i>would be a good idea, as contiguous cartograms. About the <i>contiguous cartogram</i>, one thing to remember is that it doesn't preserve, neither the position, neither the geometry so use with caution.</li>
<li>almost the same distortion can be affected to <i>interpolation </i>except it's for mathematical reasons. Interpolation is a prediction method that primarily results in a continuous image, from which no distinction can be made between the real collected values and the estimated ones. Interpolation leads to <i>contour lines</i> and <i>relief (3D or 2.5D width shaded relief)</i>.</li>
</ul>
<br />
<br />
<span style="color: orange;"><b>Isarithmic maps</b></span><br />
<span style="color: orange;"><b><br /></b></span>
Aren't these maps pretty?<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://i.stack.imgur.com/A4NI0.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="210" src="http://i.stack.imgur.com/A4NI0.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><a href="http://gis.stackexchange.com/questions/3083/examples-of-beautiful-maps">http://gis.stackexchange.com/questions/3083/examples-of-beautiful-maps</a>
</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-black.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="180" src="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-black.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><a href="http://dsparks.wordpress.com/2011/10/24/isarithmic-maps-of-public-opinion-data/">http://dsparks.wordpress.com/2011/10/24/isarithmic-maps-of-public-opinion-data/</a>
</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<br /></div>
<br />
In both cases, the same principle is used but the base layers are vectors for the first one and rasters for the second one. In each of these maps, there are two overlays. The first one is the thematic one. The second one is a mask that gives more or less importance to the overlaid data depending on its data. You probably know masks. They usually are binary. But here, it is continuous. The alpha transparency level is used as a weighted visual factor. The cities that are the most populated will be more visible, and so will be their votes. That's a pretty logical and intuitive approach.<br />
<br />
We could use this principle in many cases: attractiveness of a city, political weight, visibility of a landscape from a route.<br />
<br />
In our case, the following schema summaries the process:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvuiWTmY77kuudwFJspqsvhV8-HWtqunKe8dgwwRvPrAmEEtUXWu0SLFZymXJQWVuXk4I0onhx-gcgXjD_YmgiQU0VRY5LspjJIQUluzFUlTgIDTzZMxedhqFrZ5vk_X_KTcrb6yqnB8Q/s1600/isarithmic.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="341" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvuiWTmY77kuudwFJspqsvhV8-HWtqunKe8dgwwRvPrAmEEtUXWu0SLFZymXJQWVuXk4I0onhx-gcgXjD_YmgiQU0VRY5LspjJIQUluzFUlTgIDTzZMxedhqFrZ5vk_X_KTcrb6yqnB8Q/s400/isarithmic.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Isarithmic Map: the principle</td></tr>
</tbody></table>
<br />
Everytime a "data designer" tries to mimic nature: noise in textures, <a href="http://www.brainpickings.org/index.php/2012/01/16/manuel-lima-the-power-of-networks/" target="_blank">networks in trees</a>, <a href="http://spatialanalysis.co.uk/2012/05/mapping-city-flows-blood/" target="_blank">traffic as blood pressure along blood vessels</a>, <span id="goog_2127048512"></span>the <a href="http://www.jeromecukier.net/blog/2011/05/25/better-life-index-a-post-mortem/" target="_blank">OECD better life index as flowers</a><span id="goog_2127048513"></span>, the visualization is compelling. Here, I think the attractive aspect comes from a light sensation.<br />
<br />
In my isarithmic map, the continuous mask looks like this:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8uOAGxYQ0vUqBqGj-mV8tOqd9J2kf2piszxJN9xsyasJ9vYmJc5kdZeGFVNYmlLpyZQyXc5-ud7lah_KUvhAH3rnMxKLq2w906bz1QLJhbf13XJT3L7Ned3svpaJ4z4do6EuyKQUkAWQ/s1600/masque.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="592" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8uOAGxYQ0vUqBqGj-mV8tOqd9J2kf2piszxJN9xsyasJ9vYmJc5kdZeGFVNYmlLpyZQyXc5-ud7lah_KUvhAH3rnMxKLq2w906bz1QLJhbf13XJT3L7Ned3svpaJ4z4do6EuyKQUkAWQ/s640/masque.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">A mask with continuous transparency/alpha levels</td></tr>
</tbody></table>
You could compare it to the satellite photos you'd get from lightning in France. The mask, with its different halos of light, will enlighten some parts, but not others.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.esa.int/images/Europe-1992-2010comparesubset_L.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="228" src="http://www.esa.int/images/Europe-1992-2010comparesubset_L.gif" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><a href="http://www.esa.int/esaCP/SEMVC1EWF0H_France_1.html">http://www.esa.int/esaCP/SEMVC1EWF0H_France_1.html</a>
</td></tr>
</tbody></table>
<br />
The isarithmic map of votes:<br />
<a href="http://www.blogger.com/blogger.g?blogID=9055497882207462476#" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1O27lAU9uY5OPIJU7tEhN4pjoA0AY1_k0T1NU8oT1y6C2J_sXyX5KzG5fNjGPqKi-bN7STQXXUwn9t89L1jpziIR9rSAa_APl6tNfWj_J9r29p6lC9z-nLy89UjSQ-xyLmP5TxB4X-F4/s640/ISA_CHORO.png" width="640" /></a><br />
R was used by David B. Sparks for his opinion visualization. I used the same software for the code. Here are the technical explanations. The R code follows.<br />
<br />
<br />
<span style="color: orange;"><b>The R code: technical explanations</b></span><br />
<span style="color: orange;"><b><br /></b></span>
Half of the code, the one that consists in integrating voting results and making a choropleth, has already been treated in the <a href="http://datagistips.blogspot.fr/2012/05/resultats-du-second-tour-choroplethe.html" target="_blank">previous post</a>, so I won't detail this part.<br />
<br />
The latter half consists in creating and overlaying the continuous mask. That's what interests us, overal<br />
<br />
<br />
<span style="color: orange;">Logging the population values</span><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7lEmi3bjb1OPFU8wziq5XzTWZ-iQGLiQTy5UtTi1JzmR-Qw7Dd3HnwADmE9YebDzAB60JMCZNyQyhj7oapo7ihuuIuFUFBVD65cXm8OYHC8mfinFe1wV7vPZFD3_jDMdKckOChjf8Ork/s1600/hists.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7lEmi3bjb1OPFU8wziq5XzTWZ-iQGLiQTy5UtTi1JzmR-Qw7Dd3HnwADmE9YebDzAB60JMCZNyQyhj7oapo7ihuuIuFUFBVD65cXm8OYHC8mfinFe1wV7vPZFD3_jDMdKckOChjf8Ork/s640/hists.png" width="640" /></a> <br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb42tqszKOTg5gICMqc9Hp4sI8y3jJ8LiBBhn_qq-1GEDYNqFCD0D0_Gxk7_bISDdL-1HaEQK4fCU3MPOUDHM7qKowTkewwwOgpwI6Mof5T5V6YfIzfz9r6iStNKSba6mOmGsUynuXn8c/s1600/masque2.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="274" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb42tqszKOTg5gICMqc9Hp4sI8y3jJ8LiBBhn_qq-1GEDYNqFCD0D0_Gxk7_bISDdL-1HaEQK4fCU3MPOUDHM7qKowTkewwwOgpwI6Mof5T5V6YfIzfz9r6iStNKSba6mOmGsUynuXn8c/s640/masque2.png" width="640" /></a><br />
<br />
Initially, my mask enhanced cities with the largest population density. The intermediate cities were almost totally masked. That's why I decided to log my population values to get something more homogeneous. This histogram show the differences between the non-logged population values and the logged ones.<br />
<br />
<br />
<span style="color: orange;">How to create a continuous black mask?</span><br />
<span style="color: orange;"><br /></span>
We'll consider a base black color value: rgb(0, 0, 0)<br />
We can add a 4th argument for opacity: rgb(0, 0, 0, .5) is half transparent. <br />
Here, the color sequence will create 100 black values from 0 (transparent) to 1 (opaque).<br />
<pre class="r geshifilter-R" style="font-family: monospace;"><span style="background-color: #f3f3f3;">seqTrsp <- </span><a href="http://inside-r.org/r-doc/base/seq" style="background-color: #f3f3f3;"><span style="color: #003399; font-weight: bold;">seq</span></a><span style="background-color: #f3f3f3; color: #009900;">(</span><span style="background-color: #f3f3f3; color: #cc66cc;">0</span><span style="background-color: #f3f3f3; color: #339933;">,</span><span style="background-color: #f3f3f3;"> </span><span style="background-color: #f3f3f3; color: #cc66cc;">.8</span><span style="background-color: #f3f3f3; color: #339933;">,</span><span style="background-color: #f3f3f3;"> length.out=nCuts</span><span style="background-color: #f3f3f3; color: #009900;">)</span>
<span style="background-color: #f3f3f3;">palPop <- </span><a href="http://inside-r.org/r-doc/grDevices/rgb" style="background-color: #f3f3f3;"><span style="color: #003399; font-weight: bold;">rgb</span></a><span style="background-color: #f3f3f3; color: #009900;">(</span><span style="background-color: #f3f3f3; color: #cc66cc;">0</span><span style="background-color: #f3f3f3; color: #339933;">,</span><span style="background-color: #f3f3f3;"> </span><span style="background-color: #f3f3f3; color: #cc66cc;">0</span><span style="background-color: #f3f3f3; color: #339933;">,</span><span style="background-color: #f3f3f3;"> </span><span style="background-color: #f3f3f3; color: #cc66cc;">0</span><span style="background-color: #f3f3f3; color: #339933;">,</span><span style="background-color: #f3f3f3;"> seqTrsp</span><span style="background-color: #f3f3f3; color: #009900;">)</span> </pre>
<br />
<br />
<b style="color: orange;">Complete code on github</b><br />
<br />
<script src="https://gist.github.com/2868109.js?file=Isarithmic_Choropleth-election_results.R">
</script>harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-89278150800326278232012-06-21T02:33:00.001-07:002012-06-22T02:45:49.479-07:00Résultats gagnants par circonscription du 2nd tour des élections législatives 17 juin 2012 - Fichier Remanié d'après Data Publica<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJtCy2U45TJkl7FZtpXB2-NToMOnExcQeQHc0II38DNtNxos136rFcVE7wSNQ0KgzeX4OSoi7ETRzR5tsdrfxzLtZA_-oSG6qq3dfB4775Ro_Mu7KA5_KCvuQwLEHee3VJYAwZScnzrNc/s1600/traitement_leg.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="164" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJtCy2U45TJkl7FZtpXB2-NToMOnExcQeQHc0II38DNtNxos136rFcVE7wSNQ0KgzeX4OSoi7ETRzR5tsdrfxzLtZA_-oSG6qq3dfB4775Ro_Mu7KA5_KCvuQwLEHee3VJYAwZScnzrNc/s200/traitement_leg.png" width="200" /></a></div>
L'excellent site <a href="http://www.data-publica.com/" target="_blank">data publica</a> alimente très rapidement sa plate-forme de nouvelles données en licence ouverte. Dernières en date, les données des résultats des législatives 2012 par circonscriptions.<br />
<br />
<div style="text-align: center;">
<a href="http://www.data-publica.com/data/13622--resultat-par-circonscription-du-2nd-tour-des-elections-legislatives-17-juin-2012" target="_blank">http://www.data-publica.com/data/13622--resultat-par-circonscription-du-2nd-tour-des-elections-legislatives-17-juin-2012<span id="goog_446390123"></span><span id="goog_446390124"></span> </a></div>
<br />
Ce fichier est très complet et permet d'avoir les résultats pour chaque circonscription relatives aux différents partis.<br />
<br />
J'ai voulu créer un fichier remanié ne faisant apparaître que les gagnants. Le voici en téléchargement au format csv:<br />
<br />
<div style="text-align: center;">
<a href="https://docs.google.com/open?id=0B2ZYzwKbiu3Jek56Y2ZUcDVDWHc">https://docs.google.com/open?id=0B2ZYzwKbiu3Jek56Y2ZUcDVDWHc</a><span id="goog_930234287"></span><span id="goog_930234288"></span></div>
<div style="text-align: center;">
<br /></div>
<div style="color: orange; text-align: left;">
<b>Plan:</b></div>
<ul>
<li>Pourquoi remanier le fichier</li>
<li>Quel métier exercent les candidats ayant remporté les élections législatives? </li>
<li>Autres explorations</li>
<ul>
<li>Petits camemberts</li>
<li>Triangulaires</li>
<li>Abstention</li>
<li>Extrême-Droite </li>
</ul>
<li>Les éléments clés du code ayant permis cette transformation</li>
<li>Le code R sous github </li>
</ul>
<br />
<a name='more'></a><br />
<br />
<b><span style="color: orange;">Pourquoi remanier le fichier</span></b><br />
<br />
Il n'est pas très aisé d'avoir, à partir du fichier d'origine, les gagnants pour chaque circonscription. Pour chaque circonscription, les résultats relatifs aux candidats sont ordonnés en colonnes mais pas selon le pourcentage de vote obtenu.<br />
<br />
Il y a donc une structure en colonnes correspondant aux résultats pour un candidat qui est répliquée de 2 à trois fois. <br />
<br />
Aussi, les partis d'appartenance politique sont mentionnés par des codes. Les libellés de ces derniers sont récupérables depuis le fichier des résultats du second tour des élections présidentielles. Je les ai aussi intégrés dans le fichier final.<br />
<br />
Un remaniement du fichier serait nécessaire afin d'avoir un résultat synthétique des résultats. Il serait cohérent d'identifier les gagnants dans cette masse de données. C'est le but du traitement réalisé.<br />
<br />
Il faut signaler que le fichier comporte un tronc commun: des données générales permettant d'analyser entre autres choses l'abstention.<br />
<br />
En gros, l'opération que j'ai réalisée consiste à migrer de cette structure native de fichier à celle-ci:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJtCy2U45TJkl7FZtpXB2-NToMOnExcQeQHc0II38DNtNxos136rFcVE7wSNQ0KgzeX4OSoi7ETRzR5tsdrfxzLtZA_-oSG6qq3dfB4775Ro_Mu7KA5_KCvuQwLEHee3VJYAwZScnzrNc/s1600/traitement_leg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="524" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJtCy2U45TJkl7FZtpXB2-NToMOnExcQeQHc0II38DNtNxos136rFcVE7wSNQ0KgzeX4OSoi7ETRzR5tsdrfxzLtZA_-oSG6qq3dfB4775Ro_Mu7KA5_KCvuQwLEHee3VJYAwZScnzrNc/s640/traitement_leg.png" width="640" /></a></div>
<br />
Aussi ai-je rajouté une colonne: le nombre de candidats présents au second tour pour chaque circonscription. Ce nombre va de 1 à 3. Il permet de déterminer les triangulaires.<br />
<br />
J'espère que ce fichier vous aura permis de réaliser des analyses, voire des cartes sympathiques.<span style="color: orange;"> <span style="color: black;">D'ailleurs, voici un article mentionnant un fichier géographique des circonscriptions: <a href="http://www.joelgombin.fr/?p=649">http://www.joelgombin.fr/?p=649</a></span></span><br />
<br />
<span style="color: orange;"><span style="color: black;">Voici quelques petites statistiques que j'ai réalisées sur la base de ce fichier.</span></span><br />
<br />
<br />
<span style="color: orange;"><span style="color: black;"><b style="color: orange;">Quelle profession exercent les gagnants?</b></span></span><br />
<br />
Un article du Figaro intitulé <a href="http://elections.lefigaro.fr/presidentielle-2012/2012/06/18/01039-20120618ARTFIG00719-les-deputes-issus-des-classes-populaires-ont-disparu.php" target="_blank">"Les députés issus des classes populaires ont disparu"</a> indique que ces derniers sont à présents largement diplômés, contrairement à avant où ils étaient surtout issus de milieux modestes.<br />
<br />
Regardons quel métier ils excercent. Pour cela, il a fallu que je récupère <a href="http://www.data-publica.com/data/13587--liste-des-6603-candidats-aux-elections-legislatives-des-10-et-17-juin-2012" target="_blank">le fichier des candidats aux élections législatives</a> sur le site de data publica.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://picasaweb.google.com/lh/photo/-Xz0_l1uNK4H1SzJS83NMMMgbHW51AOnNtzKTxSCN0c?feat=directlink" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtK4rvWAgcIxUsfMAuGICX64hCC37hvaJoKr_gskfW6oxuIeGOOONUPCoLhyphenhyphenq6H16nQtMdARbMbi18grcRKa-rJJb8R-3Xz30OGnJHGXD51xycS_kqXGAHwDtdWsZ5lTrHUGHbhxe56ho/s640/profession+des+candidats.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Distribution des professions exercées par les députés</td></tr>
</tbody></table>
<br />
Dans l'article, il est également dit que côté Socialistes, la grande majorité des élus provient de l'enseignement secondaire et que le privé est davantage représenté côté Droite. Regardons le pourcentage de métier entre Gauche (Socialiste) et Droite (UMP). Cela est confirmé.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://picasaweb.google.com/lh/photo/Y3WLOT2meCV25crEzrHMusMgbHW51AOnNtzKTxSCN0c?feat=directlink" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank""><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1j8w3_8kZI_7r_U7y1HVgcld-UuKqncy9JAMHJz3i24hqc39t-VvkVsXsUQYy6-iQfwpFHLu3HdpMiR3i2V0Odcp6NjTZ40yoCiJ9L78lPSzRurGaPR1ZW5yH4_niyJxfA3FleFcOUoE/s640/m%C3%A9tier+gauche+droite.png" width="426" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Gauche Droite: les métiers des députés</td></tr>
</tbody></table>
<br />
<span style="color: orange;"><span style="color: black;"><b style="color: orange;">Autres explorations du fichier</b></span></span><br />
<br />
<br />
<span style="color: black;"><span style="color: black;"><span style="color: orange;">Petits camemberts</span></span></span><br />
<span style="color: black;"><span style="color: black;"><span style="color: orange;"><br /></span></span></span><br />
<span style="color: black;"><span style="color: black;">Voici des petits camemberts montrant la répartition des sexes et des partis représentés.</span></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://picasaweb.google.com/lh/photo/LJdKOGNGS6_OE3HduzdimMMgbHW51AOnNtzKTxSCN0c?feat=directlink" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEityzm_Ko3VpPW5U67uUqa7w-B4X_UBYtgm2B3ZiRxNoAUbKLFxFGK_WZ-kamaR5UkXvWMGfKNO2Et8lesYpM85HJD0AvzXnYO8Gr1i9guk-Ivd9xNWKCpAyPIsHKDqSnrVHyovsZydLpk/s640/pie.png" width="640" /></a></div>
<br />
Très largement, l'Assemblée Nationale se partage entre Socialistes et candidats de l'UMP et les hommes sont plus largements présents que les femmes, près des 3/4.<br />
<br />
<br />
<div style="color: orange;">
Triangulaires</div>
<div style="color: orange;">
<br /></div>
<div style="color: orange;">
<span style="color: black;">Ce tableau présente les différentes circonscriptions et partis présents aux triangulaires. </span></div>
<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Libellé.du.département Code.de.la.circonscription Nuance Nuance.1 Nuance.2<br />2 AIN 2 DVG UMP FN<br />6 AISNE 1 SOC DVG NCE<br />10 AISNE 5 RDG UMP FN<br />31 AUBE 1 RDG UMP FN<br />45 BOUCHES DU RHONE 6 VEC UMP FN<br />47 BOUCHES DU RHONE 8 SOC UMP FN<br />49 BOUCHES DU RHONE 10 VEC UMP FN<br />51 BOUCHES DU RHONE 12 SOC UMP FN<br />54 BOUCHES DU RHONE 15 DVG UMP FN<br />75 HAUTE CORSE 1 RDG REG UMP<br />93 DOUBS 4 SOC UMP FN<br />115 GARD 1 SOC NCE FN<br />116 GARD 2 SOC UMP FN<br />117 GARD 3 SOC UMP FN<br />120 GARD 6 VEC UMP FN<br />146 HERAULT 6 SOC UMP FN<br />147 HERAULT 7 SOC UMP FN<br />186 LOIRE 4 VEC UMP FN<br />245 MOSELLE 4 SOC UMP FN<br />248 MOSELLE 7 SOC PRV FN<br />275 OISE 2 SOC UMP FN<br />279 OISE 6 FG UMP FN<br />300 PYRENEES ATLANTIQUES 2 SOC CEN UMP<br />306 PYRENEES ORIENTALES 1 DVG UMP FN<br />321 HAUT RHIN 6 SOC NCE FN<br />420 VAR 2 SOC UMP FN<br />421 VAR 3 RDG UMP FN<br />425 VAR 7 DVG UMP FN<br />426 VAR 8 SOC UMP FN<br />427 VAUCLUSE 1 SOC UMP FN<br />429 VAUCLUSE 3 SOC UMP FN<br />467 HAUTS DE SEINE 6 SOC DVD DVD<br />470 HAUTS DE SEINE 9 SOC UMP DVD<br />529 WALLIS-ET-FUTUNA 1 RDG DVG DVD</span></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="color: black;"><span style="color: black;"><span style="color: orange;">Abstention </span></span></span><br />
<br />
<span style="color: black;"><span style="color: black;">Les 20 départements comportant le plus d'abstention sont les suivants </span></span><br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="color: black; font-size: x-small;"><span style="color: black;"> Libellé.du.département Code.de.la.circonscription X..Abs.Ins<br />538 FRANCAIS DE L'ETRANGER 8 87.23<br />532 FRANCAIS DE L'ETRANGER 2 84.45<br />539 FRANCAIS DE L'ETRANGER 9 81.74<br />531 FRANCAIS DE L'ETRANGER 1 80.93<br />533 FRANCAIS DE L'ETRANGER 3 79.44<br />535 FRANCAIS DE L'ETRANGER 5 79.24<br />536 FRANCAIS DE L'ETRANGER 6 77.62<br />540 FRANCAIS DE L'ETRANGER 10 76.96<br />537 FRANCAIS DE L'ETRANGER 7 75.92<br />534 FRANCAIS DE L'ETRANGER 4 73.97<br />541 FRANCAIS DE L'ETRANGER 11 73.93<br />481 SEINE SAINT-DENIS 7 68.38<br />478 SEINE SAINT-DENIS 4 67.61<br />485 SEINE SAINT-DENIS 11 67.12<br />70 CHER 2 66.43<br />271 NORD 19 66.28<br />475 SEINE SAINT-DENIS 1 66.23<br />462 HAUTS DE SEINE 1 66.08<br />513 MARTINIQUE 3 64.93<br />381 SEINE MARITIME 8 64.80</span></span></div>
<br />
<br />
<span style="color: black;"><span style="color: black;">Comme le mentionnait Data Publica sur son site, les fançais de l'étranger arrivent en tête.</span></span><br />
<br />
<br />
<span style="color: black;"><span style="color: black;"><span style="color: orange;">Extrême-Droite </span></span></span><br />
<br />
<span style="color: black;"><span style="color: black;">Les circonscriptions avec un candidat gagnant d'extrême droite: </span></span><br />
<span style="color: black;"><span style="color: black;"> </span> </span><br />
<span style="color: black;"><span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"></span><span style="font-family: "Courier New",Courier,monospace;"> Libellé.du.département Code.de.la.circonscription Nom Prénom</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">116 GARD 2 COLLARD Gilbert</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">429 VAUCLUSE 3 MARECHAL-LE PEN Marion</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">430 VAUCLUSE 4 BOMPARD Jacques</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> Nuance X..Voix.Exp ncandidats</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">116 FN 42.82 3</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">429 FN 42.09 3</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;">430 EXD 58.77 2</span></span> </span><br />
<br />
<br />
<span style="color: black;">Il me semblait correct de rendre le mécanisme, la méthode réalisée ouverts, transparents, de la même façon que le sont les données source. Par la suite, vous trouverez les aspects plus techniques liés au code puis enfin le code complet.</span><br />
<b style="color: orange;"><br /></b><br />
<b style="color: orange;"><br /></b><br />
<b style="color: orange;">Les éléments clés du code</b><br />
<br />
<div style="color: black;">
Les lots de colonnes correspondant aux différents panneaux sont stockés dans une liste.</div>
<pre class="r geshifilter-R" style="background-color: #f3f3f3; font-family: monospace;">resL <- <a href="http://inside-r.org/r-doc/base/list"><span style="color: #003399; font-weight: bold;">list</span></a><span style="color: #009900;">(</span><span style="color: #009900;">)</span>
resL<span style="color: #009900;">[</span><span style="color: #009900;">[</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">]</span><span style="color: #009900;">]</span> <- res<span style="color: #009900;">[</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">17</span>:<span style="color: #cc66cc;">24</span><span style="color: #009900;">]</span>
resL<span style="color: #009900;">[</span><span style="color: #009900;">[</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">]</span><span style="color: #009900;">]</span> <- res<span style="color: #009900;">[</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">25</span>:<span style="color: #cc66cc;">32</span><span style="color: #009900;">]</span>
resL<span style="color: #009900;">[</span><span style="color: #009900;">[</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">]</span><span style="color: #009900;">]</span> <- res<span style="color: #009900;">[</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">33</span>:<span style="color: #cc66cc;">40</span><span style="color: #009900;">]</span></pre>
<div style="color: black;">
<br /></div>
<div style="color: black;">
On détecte quel est le lot/le panneau comportant la valeur maximale</div>
<pre class="r geshifilter-R" style="background-color: #f3f3f3; font-family: monospace;">wch <- <a href="http://inside-r.org/r-doc/base/sapply"><span style="color: #003399; font-weight: bold;">sapply</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>:<a href="http://inside-r.org/r-doc/base/nrow"><span style="color: #003399; font-weight: bold;">nrow</span></a><span style="color: #009900;">(</span>res<span style="color: #009900;">)</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/function"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900;">(</span>x<span style="color: #009900;">)</span> <a href="http://inside-r.org/r-doc/base/which.max"><span style="color: #003399; font-weight: bold;">which.max</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/sapply"><span style="color: #003399; font-weight: bold;">sapply</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>:<span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/function"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900;">(</span>i<span style="color: #009900;">)</span> resL<span style="color: #009900;">[</span><span style="color: #009900;">[</span>i<span style="color: #009900;">]</span><span style="color: #009900;">]</span><span style="color: #009900;">[</span>x<span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span></pre>
<div style="color: black;">
<br /></div>
On emploie un mécanisme similaire pour avoir le nombre de candidats:<br />
<div style="background-color: #f3f3f3; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/stats/df"><span style="color: #003399; font-weight: bold;">df</span></a>$ncandidats <- <a href="http://inside-r.org/r-doc/base/sapply"><span style="color: #003399; font-weight: bold;">sapply</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>:<a href="http://inside-r.org/r-doc/base/nrow"><span style="color: #003399; font-weight: bold;">nrow</span></a><span style="color: #009900;">(</span>res<span style="color: #009900;">)</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/function"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900;">(</span>x<span style="color: #009900;">)</span> <a href="http://inside-r.org/r-doc/base/length"><span style="color: #003399; font-weight: bold;">length</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/stats/na.omit"><span style="color: #003399; font-weight: bold;">na.omit</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/sapply"><span style="color: #003399; font-weight: bold;">sapply</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>:<span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/function"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900;">(</span>i<span style="color: #009900;">)</span> resL<span style="color: #009900;">[</span><span style="color: #009900;">[</span>i<span style="color: #009900;">]</span><span style="color: #009900;">]</span><span style="color: #009900;">[</span>x<span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
<span style="color: black;">On détecte par la suite quelle est la ligne à sélectionner pour le data frame final. On crée ce dernier en assemblant les lignes.</span><br />
<pre class="r geshifilter-R" style="background-color: #f3f3f3; font-family: monospace;">rowSel <- <a href="http://inside-r.org/r-doc/base/lapply"><span style="color: #003399; font-weight: bold;">lapply</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span>:<a href="http://inside-r.org/r-doc/base/nrow"><span style="color: #003399; font-weight: bold;">nrow</span></a><span style="color: #009900;">(</span>res<span style="color: #009900;">)</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/function"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900;">(</span>x<span style="color: #009900;">)</span> resL<span style="color: #009900;">[</span><span style="color: #009900;">[</span>wch<span style="color: #009900;">[</span>x<span style="color: #009900;">]</span><span style="color: #009900;">]</span><span style="color: #009900;">]</span><span style="color: #009900;">[</span>x<span style="color: #339933;">,</span> <span style="color: #009900;">]</span><span style="color: #009900;">)</span>
dfSel <- <a href="http://inside-r.org/r-doc/base/do.call"><span style="color: #003399; font-weight: bold;">do.call</span></a><span style="color: #009900;">(</span><span style="color: blue;">"rbind"</span><span style="color: #339933;">,</span> rowSel<span style="color: #009900;">)</span></pre>
<br />
<br />
<b style="color: orange;">Le code R sous github</b><br />
<br />
<script src="https://gist.github.com/2960781.js?file=res_leg_2nd_T.R">
</script><br />
<br />harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-89622281663153157332012-06-12T23:23:00.002-07:002012-06-13T03:59:03.686-07:00HeatMap Profession ~ Parti des candidats aux élections législatives et contribution au khi-deux (suite)Dans le <a href="http://datagistips.blogspot.fr/2012/06/legislatives-2012-activite.html" target="_blank">précédent post</a>, nous avons déjà vu quelques notions permettant d'analyser le lien entre la profession exercée par les candidats aux élections législatives et leur appartenance politique.<br />
<br />
Nous aurions pu compléter l'analyse des correspondances grâce à une petite heatmap montrant les effectifs et leur aspect significatif..<br />
<br />
<div style="color: orange;">
<b>Plan:</b></div>
<ul>
<li>La HeatMap</li>
<li>Calcul du khi-deux, explications</li>
<li>Les éléments-clé du code</li>
<li>Le code complet sous github </li>
</ul>
<br />
<br />
<div style="color: orange;">
<b>La heatmap</b></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://picasaweb.google.com/lh/photo/JEa90l-tKCs5wfu-SYFYh8MgbHW51AOnNtzKTxSCN0c?feat=directlink" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH0k-MYf8K9TQI5-L4uO-nD9El4cJyGLLpJU6c3MbvTaAq5f3aOUQisUUw3I8FeNUaFaoEzhilswnNiMS8EpZ3e7X4rL40j9tSeTQMz62cam1QBZ1DltbNfVV-Xv0bOwMV9BrrlOTZhBA/s640/khikhi.png" width="341" /></a></div>
<br />
<br />
Dans cette heatmap, l'intensité de la couleur est relative à la valeur du khi-deux de la cellule (issue du couplage de deux modalités, Profession et Parti). Plus la valeur est élevée entre ces deux modalités et plus leur correspondance est élevée.<br />
<br />
<a name='more'></a>Nous avons superposé les effectifs pour une meilleure compréhension.<br />
<br />
Un effectif faible peut être associé à une valeur de khi deux élevée. Dans ce cas, cela indique que la faiblesse des effectifs est caractéristique du couplage des deux modalités.<br />
<br />
On peut prendre l'exemple de quelques cellules du tableau...<br />
<ul>
<li>L'effectif associé au couple <i>Avocat - UMP</i> est élevé de même que la valeur du khi deux. Cela indique que les candidats qui exercent le métier d'avocat sont davantage d'UMP.</li>
<li>On peut faire une observation similaire entre <i>Ouvrier </i>et<i> Extrême-Gauche</i>.</li>
<li>Pas mal de candidats <i>fonctionnaires de catégorie A</i> sont <i>socialistes</i>.</li>
<li>On a une valeur de khi deux élevée pour le duo <i>Cadre Supérieur dans le privé</i> et <i>Extrême-Gauche </i>mais un effectif faible, ce qui semble indiquer que, de manière significative, il y a très peu de candidats cadres supérieurs qui représentent ce parti.</li>
<li>Aussi, on voit que pour ce qui est des candidats <i>écologistes</i>, on retrouve beaucoup la catégorie "<i>autres professions libérales</i>". S'agit-il de <a href="http://www.professionsliberales.info/autresprofessionsliberales.html" target="_blank">professions libérales non réglementées</a> ou réglementées? Dommage que l'on n'ait pas plus de détails car c'est véritablement pour cette catégorie d'activité professionnelle que le parti Ecologiste est le mieux représenté.</li>
</ul>
<i>Attention, ceci est seulement mon interprétation des résultats et peut être sujet à observations, critiques, notamment sur la méthode statistique employée.</i> <i>N'hésitez pas à commenter.</i><br />
<br />
<br />
<b><span style="color: orange;">Calcul du khi-deux, explications</span></b><br />
<br />
Pour savoir si un lien est fort entre deux modalités, il faut savoir si l'effectif les réunissant est caractéristique. Pour cela, on prend en compte son "environnement" en lignes et colonnes dans le tableau de contingence. Si l'effectif est fort et si les effectifs des cellules en lignes, d'une part, et en colonnes, d'autre part, sont élevées, alors l'effectif fort n'est pas vraiment caractéristique du couple de modalités. Le contraste n'est pas assez fort.<br />
<br />
Afin de pouvoir quantifier le côté caractéristique d'un effectif croisant deux modalités, il faut prendre en compte les effectifs marginaux en lignes et colonnes relatifs à cette valeur. Ceux-ci correspondent aux effectifs relatifs à chaque modalité du couple en lignes et colonnes. Il faudra aussi prendre en compte l'effectif total afin de raisonner à une échelle globale, l'échelle du tableau de contingence.<br />
<br />
La valeur du khi-deux au niveau d'une cellule d'un tableau de contingence est la suivante:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpTq3KR2kDmvATSjL7C9Gr5QhiBjBZDtxEcKs_rutL_L3UaSBy8AjiZj00TEj9PrNe6oRpc8ySyAL9ZR9xylOsrD3jmUG5udAiBbQrVBdDAxEgkOCfKJyle35qTuWjL4OJvKTit2sjExI/s1600/calculkhideux.jpeg" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpTq3KR2kDmvATSjL7C9Gr5QhiBjBZDtxEcKs_rutL_L3UaSBy8AjiZj00TEj9PrNe6oRpc8ySyAL9ZR9xylOsrD3jmUG5udAiBbQrVBdDAxEgkOCfKJyle35qTuWjL4OJvKTit2sjExI/s1600/calculkhideux.jpeg" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">http://www.math.univ-toulouse.fr/~baccini/zpedago/asdm.pdf</td></tr>
</tbody></table>
<br />
<ul>
<li><i>nlh </i>est l'effectif au sein de la cellule du tableau</li>
<li><i>nl+</i> est l'effectif marginal en lignes. Si les professions sont en lignes, cela correspond au nombre de candidats exerçant la profession considérée.</li>
<li><i>n+h</i> est l'effectif marginal en colonne.</li>
<li><i>n</i> est l'effectif total, soit le nombre de candidats </li>
</ul>
La somme des khi-deux partiels des cellules donne la valeur du khi deux, totale. <br />
<br />
L'illustration ci-dessous montre les différentes valeurs de khi deux obtenues pour différents environnements lignes et colonnes au niveau d'une cellule:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjCkvFFv7TnPTYiMDEVnybam7MQnVnL-cORIJtWCT3HunXjCdjgvfpMR1G0OeiJRWz41pJDTfgSkClHK5toTuA0bWZuKo2UlKw2iDI16kLPfrVkGGXhGA47X0v8IPYvgofC54QlR3w6E8/s1600/khi2.jpeg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="190" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjCkvFFv7TnPTYiMDEVnybam7MQnVnL-cORIJtWCT3HunXjCdjgvfpMR1G0OeiJRWz41pJDTfgSkClHK5toTuA0bWZuKo2UlKw2iDI16kLPfrVkGGXhGA47X0v8IPYvgofC54QlR3w6E8/s640/khi2.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">schéma fait maison montrant la valeur du khi deux en une cellule (les cellules environnantes dont les valeurs ont changé sont en jaune)</td></tr>
</tbody></table>
<br />
Dans le premier tableau, la valeur du khi-deux vaut:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace; text-align: center;">
<b>(8-(12*11)/50)² / (12*11)/50 </b></div>
<br />
La valeur du khi-deux décroît à mesure que les valeurs environnantes approchent celles de la cellule.<br />
<br />
<br />
<br />
<b style="color: orange;">Les éléments clés du code</b><br />
<b style="color: orange;"><br /></b><br />
<div style="color: black;">
<div style="color: orange;">
Lecture du fichier Excel</div>
<div style="color: orange;">
<br /></div>
Pour lire le fichier excel des législatives, j'utilise la librairie <a href="http://www.portailsig.org/content/r-comment-importer-les-fichiers-microsoft-excel-traiter-eventuellement-les-donnees-r-spatial" target="_blank"><i>gdata</i></a>. La deuxième feuille comprend le tableau de correspondances entre code des partis (encore appelé nuance) et libellé de ces derniers.</div>
<pre class="r geshifilter-R" style="background-color: #f3f3f3; font-family: monospace;">f <- read.xls<span style="color: #009900;">(</span><span style="color: blue;">"IN/Leg 2012 Candidatures T1 31 05 2012.xls"</span><span style="color: #339933;">,</span> sheet=<span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span>
nuances <- read.xls<span style="color: #009900;">(</span><span style="color: blue;">"IN/Leg 2012 Candidatures T1 31 05 2012.xls"</span><span style="color: #339933;">,</span> sheet=<span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> skip=<span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> header=<span style="color: black; font-weight: bold;">FALSE</span><span style="color: #009900;">)</span></pre>
<div style="color: black;">
<br />
<span style="color: orange;">Reshape Casting</span><br />
<br /></div>
<span style="color: orange;"><span style="color: black;">Comme mentionné dans le post précédent, l'obtention du tableau de contingence a nécessité un reshaping de la donnée initiale en basculant les partis en colonnes. Cela se fait avec la fonction <i>cast </i>de la librairie <a href="http://www.statmethods.net/management/reshape.html" target="_blank"><i>reshape</i></a></span></span><br />
<pre class="r geshifilter-R" style="background-color: #f3f3f3; font-family: monospace;">f$value <- <span style="color: #cc66cc;">1</span>
r <- cast<span style="color: #009900;">(</span>f<span style="color: #009900;">[</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/c"><span style="color: #003399; font-weight: bold;">c</span></a><span style="color: #009900;">(</span><span style="color: blue;">"Profession"</span><span style="color: #339933;">,</span> <span style="color: blue;">"NuanceLib"</span><span style="color: #339933;">,</span> <span style="color: blue;">"value"</span><span style="color: #009900;">)</span><span style="color: #009900;">]</span><span style="color: #339933;">,</span> Profession~NuanceLib<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/sum"><span style="color: #003399; font-weight: bold;">sum</span></a><span style="color: #009900;">)</span></pre>
<br />
<span style="color: orange;">Fonction de calcul du khi-deux</span><br />
<br />
<div style="color: black;">
J'ai réalisé une fonction permettant de calculer le khi deux au sein de chaque cellule du tableau et obtenir une matrice de contribution au khi-deux.</div>
<pre class="r geshifilter-R" style="background-color: #f3f3f3; font-family: monospace;">khideux <- <a href="http://inside-r.org/r-doc/base/function"><span style="color: #003399; font-weight: bold;">function</span></a><span style="color: #009900;">(</span>mat<span style="color: #009900;">)</span><span style="color: #009900;">{</span>
m.cont <- mat
sumR <- <a href="http://inside-r.org/r-doc/base/apply"><span style="color: #003399; font-weight: bold;">apply</span></a><span style="color: #009900;">(</span>mat<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/sum"><span style="color: #003399; font-weight: bold;">sum</span></a><span style="color: #009900;">)</span>
sumC <- <a href="http://inside-r.org/r-doc/base/apply"><span style="color: #003399; font-weight: bold;">apply</span></a><span style="color: #009900;">(</span>mat<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/sum"><span style="color: #003399; font-weight: bold;">sum</span></a><span style="color: #009900;">)</span>
sumT <- <a href="http://inside-r.org/r-doc/base/sum"><span style="color: #003399; font-weight: bold;">sum</span></a><span style="color: #009900;">(</span>mat<span style="color: #009900;">)</span>
<span style="color: black; font-weight: bold;">for</span> <span style="color: #009900;">(</span>i <span style="color: black; font-weight: bold;">in</span> <span style="color: #cc66cc;">1</span>:<a href="http://inside-r.org/r-doc/base/nrow"><span style="color: #003399; font-weight: bold;">nrow</span></a><span style="color: #009900;">(</span>mat<span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
<span style="color: black; font-weight: bold;">for</span> <span style="color: #009900;">(</span>j <span style="color: black; font-weight: bold;">in</span> <span style="color: #cc66cc;">1</span>:<a href="http://inside-r.org/r-doc/base/ncol"><span style="color: #003399; font-weight: bold;">ncol</span></a><span style="color: #009900;">(</span>mat<span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span>
w <- <span style="color: #009900;">(</span>sumR<span style="color: #009900;">[</span>i<span style="color: #009900;">]</span>*sumC<span style="color: #009900;">[</span>j<span style="color: #009900;">]</span><span style="color: #009900;">)</span>/sumT
khikhi <- <span style="color: #009900;">(</span>mat<span style="color: #009900;">[</span>i<span style="color: #339933;">,</span> j<span style="color: #009900;">]</span> - w<span style="color: #009900;">)</span>^<span style="color: #cc66cc;">2</span>/w
m.cont<span style="color: #009900;">[</span>i<span style="color: #339933;">,</span> j<span style="color: #009900;">]</span> <- khikhi
<span style="color: #009900;">}</span>
<span style="color: #009900;">}</span>
<a href="http://inside-r.org/r-doc/base/return"><span style="color: #003399; font-weight: bold;">return</span></a> <span style="color: #009900;">(</span>m.cont<span style="color: #009900;">)</span>
<span style="color: #009900;">}</span>
m.cont <- khideux<span style="color: #009900;">(</span>r.m<span style="color: #009900;">)</span></pre>
<br />
<span style="color: black;"><span style="color: orange;">HeatMap </span></span><br />
<br />
<span style="color: black;">Il existe une fonction native dans R appelée <i>heatmap. </i>Elle n'a pas été utilisée ici car je n'ai pas trouvé de moyen de spécifier les points de cassure pour les couleurs (break= )</span><span style="color: orange;"><span style="color: black;">. J'ai donc utilisé la fonction <i><a href="http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/image.html" target="_blank">image</a> </i>qui permet de paramétrer de manière plus fine la représentation graphique d'une heatmap.</span></span><br />
<div style="background-color: #f3f3f3; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/image"><span style="color: #003399; font-weight: bold;">image</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/t"><span style="color: #003399; font-weight: bold;">t</span></a><span style="color: #009900;">(</span>m.cont2<span style="color: #009900;">)</span><span style="color: #339933;">,</span> breaks=cls$brk<span style="color: #339933;">,</span> axes=F<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=pal<span style="color: #009900;">(</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
<span style="color: orange;">Libellés</span><br />
<br />
<span style="color: orange;"><span style="color: black;">Pour les libellés, il a fallu tout d'abord que je détermine la position/les coordonnées de chaque label au sein du tableau. Pour un tableau de 3 colonnes et 2 lignes, la séquence de coordonnées est la suivante pour les x: 123 123 et pour les y: 111 222. Les cycles sont différents. Dans le deuxième cas, on utilisera each, dans le premier non.</span></span><br />
<pre class="r geshifilter-R" style="background-color: #f3f3f3; font-family: monospace;">xs <- <a href="http://inside-r.org/r-doc/base/seq"><span style="color: #003399; font-weight: bold;">seq</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> length.out=<a href="http://inside-r.org/r-doc/base/ncol"><span style="color: #003399; font-weight: bold;">ncol</span></a><span style="color: #009900;">(</span>r.m<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
ys <- <a href="http://inside-r.org/r-doc/base/seq"><span style="color: #003399; font-weight: bold;">seq</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> length.out=<a href="http://inside-r.org/r-doc/base/nrow"><span style="color: #003399; font-weight: bold;">nrow</span></a><span style="color: #009900;">(</span>r.m<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
xs2 <- <a href="http://inside-r.org/r-doc/base/rep"><span style="color: #003399; font-weight: bold;">rep</span></a><span style="color: #009900;">(</span>xs<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/nrow"><span style="color: #003399; font-weight: bold;">nrow</span></a><span style="color: #009900;">(</span>r.m<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
ys2 <- <a href="http://inside-r.org/r-doc/base/rep"><span style="color: #003399; font-weight: bold;">rep</span></a><span style="color: #009900;">(</span>ys<span style="color: #339933;">,</span> each = <a href="http://inside-r.org/r-doc/base/ncol"><span style="color: #003399; font-weight: bold;">ncol</span></a><span style="color: #009900;">(</span>r.m<span style="color: #009900;">)</span><span style="color: #009900;">)</span></pre>
<br />
<span style="color: orange;"><span style="color: black;">Puis ensuite, j'ai pu procéder à leur affichage</span></span><br />
<div style="background-color: #f3f3f3; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/text"><span style="color: #003399; font-weight: bold;">text</span></a><span style="color: #009900;">(</span>xs2<span style="color: #339933;">,</span> ys2<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/labels"><span style="color: #003399; font-weight: bold;">labels</span></a>=<a href="http://inside-r.org/r-doc/base/ifelse"><span style="color: #003399; font-weight: bold;">ifelse</span></a><span style="color: #009900;">(</span>v><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> v<span style="color: #339933;">,</span> <span style="color: black; font-weight: bold;">NA</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=<a href="http://inside-r.org/r-doc/grDevices/gray"><span style="color: #003399; font-weight: bold;">gray</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">.5</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> cex=fsz*<span style="color: #cc66cc;">.6</span><span style="color: #339933;">,</span> font=<span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<span style="color: orange;"><span style="color: black;"><br /></span></span><br />
<br />
<span style="color: orange;"><span style="color: black;"><b style="color: orange;">Le code sous gihub</b></span></span><br />
<br />
<div style="color: black;">
<script src="https://gist.github.com/2922088.js?file=heatmap_candidats_profession.R">
</script><b><br /></b></div>
<div style="color: black;">
<b><br /></b></div>
<div style="color: black;">
<b><br /></b></div>
<br />
<br />harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com1tag:blogger.com,1999:blog-9055497882207462476.post-3641075285489014652012-06-06T10:49:00.002-07:002012-06-06T23:53:42.942-07:00Législatives 2012: Activité Professionnelle et Appartenance PolitiqueIci, nulle géographie, nous allons exploiter les données du fichier des élections législatives. Il est téléchargeable à cette adresse:<br />
<a href="http://www.data-publica.com/data/13587--liste-des-6603-candidats-aux-elections-legislatives-des-10-et-17-juin-2012">http://www.data-publica.com/data/13587--liste-des-6603-candidats-aux-elections-legislatives-des-10-et-17-juin-2012</a><br />
<br />
Ce fichier a déjà fait l'objet d'analyses sur des blogs:<br />
<ul>
<li><a href="http://blog.veronis.fr/2012/05/legislatives-philippe-et-catherine-les.html" target="_blank">sur les prénoms des candidats</a></li>
<li><a href="http://coulmont.com/blog/2012/05/30/qui-se-ressemble/" target="_blank">sur la relation avec la suppléance en terme d'écart d'âge</a></li>
<li><a href="http://blog.veronis.fr/2012/05/legislatives-carte-de-france-de-la-non.html" target="_blank">sur la parité homme-femme</a> </li>
<li><a href="http://www.data-publica.com/content/2012/06/quelles-professions-exercent-les-candidats-aux-elections-legislatives-de-lump-et-du-parti-socialiste/" target="_blank">sur les professions des candidats socialistes et UMP</a></li>
</ul>
Le fichier des élections législatives possède deux informations que nous allons utiliser spécifiquement ici: la profession du candidat et son affiliation à un parti, ceci afin de voir s'il existe un lien entre les deux.<br />
<br />
<br />
<div style="color: orange;">
<b>Plan:</b></div>
<ul>
<li>Tableau de contingence et visualisation</li>
<li>Classification hiérarchique</li>
<li>Analyse Factorielle des Correspondances</li>
</ul>
<a name='more'></a><br />
<br />
<b style="color: orange;">Tableau de contingence et visualisation</b><br />
<br />
Ces informations apparaissent toutes deux en lignes: il existe une colonne pour identifier la profession, une autre pour le parti. Nous allons transformer le fichier un petit peu afin de procéder à notre analyse, en ayant en lignes les métiers, en colonnes les différents partis et au sein du tableau, les valeurs d'effectifs. Nous allons aboutir à ce que l'on appelle un tableau de contingence.<br />
<br />
En proportions, cela donne:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://picasaweb.google.com/lh/photo/OzwOszqOtF169c7I6ooU5cMgbHW51AOnNtzKTxSCN0c?feat=directlink" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaEjCc32JC2N0tn9lXhFzV0D-nC0NfRJzFLLqQCnj8ILEFKib45-_nldf-1OZ0hmL06_gnZcUVDog4fWj9VAjm63BgNiVFtRp7PNYyqeC9R1s1jP80uildh96_HbSPBc6HjId0xJm7FyM/s640/table.png" width="341" /></a></div>
<br />
<br />
<br />
<br />
<b style="color: orange;">Classification hiérarchique</b><br />
<br />
On peut essayer de dégager une hiérarchie, une classification des différentes activités professionnelles en prenant en compte les effectifs des activités pros au sein de chaque parti.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://picasaweb.google.com/lh/photo/ChrleS0wj9Y51xHgOaHAwcMgbHW51AOnNtzKTxSCN0c?feat=directlink" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJXhls0Mh4ZTY7obAlzSiU9lzJfgNNuF3sCHum7hp8l8mJdbhBaMDqRd2iN1Qko_cT5Z-ztFjivot7vyihggOaH-1IpoKbEluIifs98HXjx2Gz6_gVgwEBWqqTKUTAWtrk5nHlQPVGpq8/s640/cluster2.png" width="426" /></a></div>
<br />
<br />
Certains regroupements sont peu surprenants:<br />
<ul>
<li>Les cadres semblent afficher le même bord politique: cadre supérieur, ingénieur, chef d'entreprise</li>
<li>De même que ceux qui le porte-feuille de clients (assez surprenant!): expert comptable, agent d'assurances, notaire, ...</li>
<li>Aussi, des candidats qui travaillent dans le domaine du bâtiment: entrepreneur en bâtiments, contremaitre, architecte.</li>
<li>Des professions médicales: dentiste, chirurgien, vétérinaire</li>
<li>Des activités liées à la créativité: homme de lettres et artiste, artisan, journaliste et autre média. </li>
<li>Des commerçants aussi sont regroupés</li>
</ul>
<br />
Par contre, on ne sait toujours pas quelle relation lie chacune des activités professionnelles aux partis. Si le candidat est ouvrier, chef d'entreprise ou enseignant, vers quel parti tendra-t-il à se rapprocher et ce lien est-t-il fort?<br />
<br />
<br />
<b style="color: orange;">Analyse factorielle des correspondances</b><br />
<br />
On peut aller plus loin en effectuant une analyse factorielle de correspondances.<br />
Sur le blog de <a href="http://francoisguillem.fr/" target="_blank">François Guillem</a> ainsi que sur <a href="http://coulmont.com/blog/" target="_blank">le blog de Jean-Baptiste Coulmont</a>, on trouve des applications très sympathiques de l'ACP.<br />
<br />
Dans notre cas, on effectuerait une ACP si l'on avait une liste d'individus et un score d'appartenance aux idées de chaque parti pour chacun d'eux, sans que l'on ne connaisse rien d'eux. Cette analyse aboutirait à l'analyse de relations entre partis, voire entre des individus et des partis.<br />
<br />
Une AFC est comparable à une ACP, à ceci près qu'elle prend en entrée deux variables qualitatives au lieu d'une. Il s'agit d'une ACP particulière qui, en superposant une ACP sur le profil-lignes (ici, les activités professionnelles) et une autre sur le profil-colonnes (nature du parti), permet de dégager des proximités entre les différentes modalités inhérentes aux deux variables.<br />
<br />
La prudence est de mise dans une AFC lorsque les effectifs sont faibles. Voici un classement dans l'ordre croissant des effectifs marginaux des activités professionnelles (somme de tous les effectifs par parti pour chaque métier).<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://picasaweb.google.com/lh/photo/K0sJVf6rUyH98uNYvah8acMgbHW51AOnNtzKTxSCN0c?feat=directlink" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuNDt-WxoqWLpUjWafkU-hSvFghKVSPp7eP_aQiaoeVSb4K4_9X6fHS62S0xMu4KRdTwkOHDzRL_u-zf00nHQ8fWMiVsvaV6s7vzPwqKjJnG9z4j3DY4jPYdL5JYjgoy2NnQdkktD4lSg/s640/eff.png" width="426" /></a></div>
<br />
<br />
Un résumé rapide d'une AFC sur notre pool de données législatives donne ceci:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> eigenvalue percentage of variance cumulative percentage of variance</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">dim 1 0.24250254 38.284494 38.28449</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">dim 2 0.13548582 21.389491 59.67398</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">dim 3 0.05178132 8.174848 67.84883</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">dim 4 0.04483564 7.078317 74.92715</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">dim 5 0.03231638 5.101869 80.02902</span></div>
<div style="font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">dim 6 0.02886831 4.557514 84.58653</span></div>
<br />
Dans le meilleur des cas, les deux premières dimensions suffisent à expliquer en grande partie l'inertie totale/la variance de notre nuage de points mais ici, à elles deux, elles n'en restituent que 59.7 %, soit un peu plus de la moitié et moins des 2/3. A partir de la troisième dimension, les inerties partielles attribuées aux axes sont assez faibles et égales. On s'arrêtera à deux axes quand même en ayant intégré cette lacune.<br />
<br />
Voici le graphique de notre AFC:<br />
<br />
<a href="https://picasaweb.google.com/lh/photo/lu4cTNscj5EfyIfXRhv3PMMgbHW51AOnNtzKTxSCN0c?feat=directlink" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4LJguguR7Jpd6s89ahWQ76bRnJhhCwgEqmqSbyRpj1CzJPS64asTLI6hizrK5AIqK7582t3udg5usQ8qJexf0CO8TXG6LFn8SN6p0rKKJ_KvelSXcMs2DnskJQoOYok7ocslkie0HAig/s640/afc.png" width="640" /></a><br />
<br />
Pour pouvoir définir nos axes, on utilise deux notions: la première est la contribution à l'inertie principale selon un axe, la deuxième, le cosinus carré.<br />
<ol>
<li>La première se calcule en utilisant les coordonnées de la modalité considérée, son effectif marginal, l'effectif total des candidats ainsi que l'interie principale de l'axe. Elle ne favorise pas les métiers où il existe peu de candidats. </li>
<li>Le cosinus carré permet, par une simple formule trigonométrique autour des coordonnées d'une modalité, de déterminer la qualité de la représentation d'une modalité selon l'axe considéré.</li>
</ol>
<br />
Les modalités les plus contributives serviront de fil directeur afin de définir nos axes.<br />
<br />
<b style="color: orange;">Axe 1</b><br />
<br />
<span style="color: orange;">Pour les lignes</span><br />
<br />
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Dim 1 Dim 2 Dim 3<br />Ouvrier (secteur privé) 13.826404 0.006545828 1.028070e-02<br />Professeur du secondaire et techn. 11.146823 3.325899414 3.222432e+00<br />Enseignant 1er deg.-directeur école 8.169252 1.617955387 9.755707e-01<br />Industriel-Chef entreprise 6.909406 1.452912388 8.674976e+00<br />Cadre supérieur (secteur privé) 6.033875 2.415535798 3.407859e+00<br />Fonctionnaire de catégorie B 5.705795 0.205800913 1.476177e-02<br />Avocat 4.859643 1.857456635 2.092405e-01<br />Employé (autres entrep. publiques) 4.588501 0.062211865 3.014305e-05<br />Agent technique et technicien 3.611098 0.503568174 8.181242e-01<br />Grands corps de l'état 3.332086 7.191733408 1.909935e+00</span></div>
<br />
On observe que des catégories socio-professionnelles sont très bien représentées selon cet axe, en particulier si l'on considère la profession d'ouvrier et de cadre supérieur, chef d'entreprise. Ces deux catégories s'opposent nettement selon l'axe1. Pour des valeurs de très bonne contribution, on retrouve d'ailleurs de très bonnes qualités de représentation (cosinus carrés): Fonctionnaire de catégorie B, ouvrier..<br />
L'axe 1 semble également afficher un gradient dans les revenus, de l'ouvrier, du salarié agricole au chirurgien, au cadre supérieur.<br />
<br />
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Dim 1 Dim 2 Dim 3</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Fonctionnaire de catégorie B 0.8445433 0.017018866 4.665529e-04</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Employé (autres entrep. publiques) 0.8352921 0.006327298 1.171687e-06</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Enseignant 1er deg.-directeur école 0.8210169 0.090847686 2.093560e-02</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Ouvrier (secteur privé) 0.7928073 0.000209701 1.258745e-04 </span></div>
<br />
<br />
<span style="color: orange;">Pour les colonnes</span><br />
<br />
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Dim 1 Dim 2 Dim 3</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Extrême gauche 53.6458070 3.685077e-01 0.586280</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Union pour un Mouvement Populaire 20.5045345 9.552070e+00 6.440497</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Front de gauche 8.7616438 6.926126e+00 2.052448</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Divers droite 6.3457991 5.398400e+00 4.939185</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Socialiste 2.2204804 2.743800e+01 1.195895</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Parti radical 2.1260108 3.077681e-01 3.394504</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Le Centre pour la France 2.0347689 4.064435e-01 10.014818</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Autres 1.2411170 1.353765e+01 16.187905</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Nouveau Centre 1.1801562 4.032157e-04 2.733341</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Alliance centriste 0.4726506 9.336666e-02 1.076020</span></div>
<br />
<br />
Il n'y a que pour l'extrême gauche et l'UMP que l'on observe de fortes contributions. Ces deux partis s'opposent d'ailleurs très nettement selon l'axe 2. Les partis "minoritaires" sont assez mal représentés selon cette dimension. On ne peut dire cependant dire que l'axe 1 représente des extrêmes dans les idées car la contribution de l'extrême droite est peu élevée. L'axe 1 semble opposer les conservateurs et les autres.<br />
<br />
<br />
<b><span style="color: orange;">Axe 2</span></b><br />
<br />
<div style="color: orange;">
Pour les lignes et colonnes selon l'axe 2</div>
<br />
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Dim 1 Dim 2 Dim 3</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Fonctionnaire de catégorie A 5.844613e-03 14.782627 0.04618557</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Employé (secteur privé) 1.302235e+00 11.858040 4.46289301</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Retraité de l'enseignement 1.212100e+00 7.494665 0.83004297</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Grands corps de l'état 3.332086e+00 7.191733 1.90993498</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Etudiant 7.154676e-04 5.870858 7.52139123</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Autre retraité 1.260179e-01 4.951988 4.13172449</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Permanent politique 2.506618e+00 4.307984 7.17496219</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Professeur du secondaire et techn. 1.114682e+01 3.325899 3.22243177</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Retr.artis.commerc.chef d entrep. 6.103767e-01 3.053174 10.53309174</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;">Commercant 3.706510e-01 2.908927 0.50359611</span></div>
<div style="color: #666666;">
<br /></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Dim 1 Dim 2 Dim 3</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Socialiste 2.220480421 27.438003 1.195895249</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Ecologiste 0.005144083 15.292174 2.809477381</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Autres 1.241116999 13.537654 16.187904983</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Front National 0.191649846 11.166394 31.816832284</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Union pour un Mouvement Populaire 20.504534463 9.552070 6.440496989</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Front de gauche 8.761643759 6.926126 2.052447511</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Divers droite 6.345799136 5.398400 4.939184582</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Extrême droite 0.247869905 3.610187 12.713174193</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Radical de Gauche 0.362048589 2.962734 0.052368789</span></div>
<div style="color: black; font-family: "Courier New",Courier,monospace;">
<span style="font-size: x-small;"> Divers gauche 0.339019594 1.675900 0.006959395</span></div>
<br />
<br />
L'analyse selon la dimension 2 est plus délicate. Nous nous contenterons de l'analyse selon la première dimension..<br />
<br />
En considérant le nuage de points, de manière globale, il apparaît que les professions exercées par les candidats correspondent aux franges de population qu'ils sont censés défendre. Il n'y a pas vraiment d'antagonisme entre le métier exercé et le parti de ralliement. Peu de professions d'encadrement du côté de l'extrême gauche et inversement du côté de celui de l'UMP.<br />
<br />
Il faut bien se remémorer que la somme des inerties principales des 2 axes n'est est que légèrement supérieure à la moitié, ce qui rend l'analyse moins fiable que dans ces cas on l'on retrouve une très forte contribution des 2 axes (supérieure à 80%). De plus, il y a peu de candidats exerçant certains métiers (salarié agricole, notaire, agent d'affaires...), ce qui rend l'analyse d'autant plus délicate pour ces éléments-là.<br />
<br />
Si l'on avait préalablement réduit les classes pour les activités professionnelles: métiers manuels, relationnels, médicaux, libéraux ainsi que les partis en classes de partis: modéré, extrême, marginal, gauche ou droite, nous aurions sans doute eu une AFC de meilleure qualité.harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-24841530548310884342012-05-15T20:00:00.000-07:002012-06-02T01:00:55.111-07:00Résultats du second tour: Nature du vote et Distance au littoral<div style="background-color: white; text-align: right;">
<span style="background-color: #fff2cc;">Article en français</span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKM0q93CzsP57qXGA1bljj2xWFjnDs5uyp-eHZWsTzUmVHKv9upYk3Nne-5N6M5ige1Q9sOsr5Bvh2BXsbefUeDZ7I5Uv5GobDrcgxleGP2EyqlC2BadMjuAazilPeHb7v6b_rUKrDQmA/s1600/test.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="88" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKM0q93CzsP57qXGA1bljj2xWFjnDs5uyp-eHZWsTzUmVHKv9upYk3Nne-5N6M5ige1Q9sOsr5Bvh2BXsbefUeDZ7I5Uv5GobDrcgxleGP2EyqlC2BadMjuAazilPeHb7v6b_rUKrDQmA/s200/test.png" width="200" /></a></div>
<b>French elections: nature of votes versus distance to the coast :</b> In the previous post, we saw how to make a simple choropleth of votes. Here, I detail how to create a dataviz combining a map and a standard xy plot to visualize the relation that exists between the nature of votes and the distance to the coast. A good opportunity to use a very interesting <a href="http://www.r-project.org/" target="_blank">R</a> library: <a href="http://www.spatstat.org/" target="_blank">spatstat</a>.<br />
<br />
<br />
<a name='more'></a> Dans le <a href="http://datagistips.blogspot.fr/2012/05/resultats-du-second-tour-choroplethe.html" target="_blank">précédent post</a>, nous avons vu comment ajouter les résultats du vote à de la donnée spatialisée afin d'aboutir à une petite choroplèthe des résultats:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCXlroPBf7Qyd3A1nIqmJV2cdAIPbMsGJKBeyx-HWBp2R8rsAgEifDKntw_iuRErdM2YkaQMPuNWBvDh-WgxvRvskJqIhS4RPUh5H8RfYIPZwQJHZCJ19OncNjoyKUrESqeODxP7evHwo/s1600/Rplot06.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCXlroPBf7Qyd3A1nIqmJV2cdAIPbMsGJKBeyx-HWBp2R8rsAgEifDKntw_iuRErdM2YkaQMPuNWBvDh-WgxvRvskJqIhS4RPUh5H8RfYIPZwQJHZCJ19OncNjoyKUrESqeODxP7evHwo/s640/Rplot06.png" width="640" /></a></div>
<br />
Avant de réaliser l'article sur la réalisation d'une carte isarithmique et de partir en week-end prolongé :), je vous propose ici un petit article sur une méthode de représentation graphique de la relation existant entre la nature des votes et la distance séparant chaque commune au littoral.<br />
<br />
Pour cela, dans un premier temps, il faut télécharger le trait de côte disponible sur le site du Service Hydrographique et Océanique de la Marine:<br />
<br />
<div style="text-align: center;">
<a href="http://www.shom.fr/fr_page/fr_prod_num/tch_licence.html">http://www.shom.fr/fr_page/fr_prod_num/tch_licence.html</a></div>
<br />
La représentation que nous allons voir se prête assez peu, en soi, à l'analyse mais elle nous permettra de voir comment utiliser la librairie spatiale R <a href="http://www.spatstat.org/" target="_blank">spatstat</a> à travers le calcul de distance au plus proche voisin, et de voir l'affichage de graphiques.<br />
<br />
Voici le code en entier. Les explications suivent par la suite:<br />
<script src="https://gist.github.com/2857215.js?file=elections_distance_coast.R"></script>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKM0q93CzsP57qXGA1bljj2xWFjnDs5uyp-eHZWsTzUmVHKv9upYk3Nne-5N6M5ige1Q9sOsr5Bvh2BXsbefUeDZ7I5Uv5GobDrcgxleGP2EyqlC2BadMjuAazilPeHb7v6b_rUKrDQmA/s1600/test.png" style="margin-left: 1em; margin-right: 1em;"><br /></a> <br />
Voici le résultat:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKM0q93CzsP57qXGA1bljj2xWFjnDs5uyp-eHZWsTzUmVHKv9upYk3Nne-5N6M5ige1Q9sOsr5Bvh2BXsbefUeDZ7I5Uv5GobDrcgxleGP2EyqlC2BadMjuAazilPeHb7v6b_rUKrDQmA/s1600/test.png" style="margin-left: auto; margin-right: auto;"><img border="0" height="283" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKM0q93CzsP57qXGA1bljj2xWFjnDs5uyp-eHZWsTzUmVHKv9upYk3Nne-5N6M5ige1Q9sOsr5Bvh2BXsbefUeDZ7I5Uv5GobDrcgxleGP2EyqlC2BadMjuAazilPeHb7v6b_rUKrDQmA/s640/test.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Nature du vote et distance au littoral</td></tr>
</tbody></table>
<br />
<b style="color: orange;">Le code expliqué:</b><br />
<br />
Afin de déterminer la distance séparant chaque commune au trait de côte, on va utiliser la librairie <a href="http://www.spatstat.org/" target="_blank">spatstat</a>. Celle-ci n'utilise pas les mêmes types d'objets que les librairies spatiales standardes, à savoir SpatialPoints/Lines/Polygones. Pour les points, elle définit la classe <a href="http://www.inside-r.org/packages/cran/spatstat/docs/ppp.object" target="_blank">ppp</a> et pour les lignes, la classe <a href="http://www.inside-r.org/packages/cran/spatstat/docs/psp" target="_blank">psp</a>. On effectue en préalable une coercion des classes SpatialPoints/Lines vers ppp et psp afin de pouvoir utiliser les données spatiales dans spatstat. <br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">tc <- readOGR<span style="color: #009900;">(</span><span style="color: blue;">"F:/DATAS/TRAIT_COTE/TCH.shp"</span><span style="color: #339933;">,</span> <span style="color: blue;">"TCH"</span><span style="color: #009900;">)</span>
tc.psp <- <a href="http://inside-r.org/r-doc/methods/as"><span style="color: #003399; font-weight: bold;">as</span></a><span style="color: #009900;">(</span>tc<span style="color: #339933;">,</span> <span style="color: blue;">"psp"</span><span style="color: #009900;">)</span>
comm.pp <- SpatialPointsDataFrame<span style="color: #009900;">(</span>coordinates<span style="color: #009900;">(</span>comm2<span style="color: #009900;">)</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/utils/data"><span style="color: #003399; font-weight: bold;">data</span></a>=comm2@<a href="http://inside-r.org/r-doc/utils/data"><span style="color: #003399; font-weight: bold;">data</span></a><span style="color: #009900;">)</span>
comm.pp <- <a href="http://inside-r.org/r-doc/methods/as"><span style="color: #003399; font-weight: bold;">as</span></a><span style="color: #009900;">(</span>comm.pp<span style="color: #339933;">,</span> <span style="color: blue;">"ppp"</span><span style="color: #009900;">)</span></pre>
<br />
Une fois cela fait, on peut alors utiliser la fonction <a href="http://www.inside-r.org/packages/cran/spatstat/docs/nncross" target="_blank">nncross</a>. Celle-ci permet de déterminer le voisin le plus proche (segment ou point) ainsi que la distance qui le sépare de ce dernier. <br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">nn <- <a href="http://inside-r.org/packages/cran/spatstat">spatstat</a>::nncross<span style="color: #009900;">(</span>comm.pp<span style="color: #339933;">,</span> tc.psp<span style="color: #009900;">)</span></pre>
<br />
On peut regarder ce que cela donne au niveau des distances commune - littoral. Pour cela, on utilise la fonction <a href="http://www.inside-r.org/packages/cran/sp/docs/spplot" target="_blank">spplot</a> qui adapte les fonctions d'affichage graphique de la librairie lattice aux objets géographiques. C'est une autre possibilité d'affichage, en plus de la fonction de base plot vue dans le post précédent.<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">comm2$dist <- nn$dist
spplot<span style="color: #009900;">(</span>comm2<span style="color: #339933;">,</span> <span style="color: blue;">"dist"</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=<span style="color: black; font-weight: bold;">NA</span><span style="color: #009900;">)</span></pre>
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEz5SI_fgNotOJjDPHY6aMbT37_ZJHbA8c_r6f1j1h95jqRearZiP9SGQo38WXgspuEwEojbbgQcpxuKg86bYs2pXdSASmAF_HLwKskHFx5pNr_U5OD0l3ZAMOYmvpbIxMwOw97_sJT08/s1600/distancesComm.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEz5SI_fgNotOJjDPHY6aMbT37_ZJHbA8c_r6f1j1h95jqRearZiP9SGQo38WXgspuEwEojbbgQcpxuKg86bYs2pXdSASmAF_HLwKskHFx5pNr_U5OD0l3ZAMOYmvpbIxMwOw97_sJT08/s400/distancesComm.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Distances entre chaque commune et le littoral</td></tr>
</tbody></table>
<div style="text-align: right;">
<i>PS: on dirait du raster mais ça n'en est pas :)</i></div>
<br />
Les données que l'on va utiliser pour les représentations suivantes sont:<br />
- Les <b>coordonnées xy </b>des centroïdes de communes <br />
- Le <b>pourcentage de vote</b> pour l'un et l'autre des candidats<br />
- La <b>distance </b>de séparation commune - trait de côte<br />
<br />
Nous allons créer un data.frame exprès pour cela, concentrant toutes ces informations: <br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/stats/df"><span style="color: #003399; font-weight: bold;">df</span></a> <- <a href="http://inside-r.org/r-doc/base/data.frame"><span style="color: #003399; font-weight: bold;">data.frame</span></a><span style="color: #009900;">(</span>pcsar=comm2$pc.sar<span style="color: #339933;">,</span> x=comm.pp$x<span style="color: #339933;">,</span> y=comm.pp$y<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/stats/dist"><span style="color: #003399; font-weight: bold;">dist</span></a>=nn$dist<span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
Attaquons-nous aux graphiques.<br />
<br />
On va utiliser une couleur <b style="color: red;">rouge </b>pour les votes dominants de gauche et <b style="color: blue;">bleue </b>pour ceux de droite (logique). Contrairement à avant, on n'utilisera pas de nuance liée au pourcentage. On intègre également une valeur de transparence de 10%. <br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">alpha <- <span style="color: #cc66cc;">.1</span>
cols <- <a href="http://inside-r.org/r-doc/grDevices/rgb"><span style="color: #003399; font-weight: bold;">rgb</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/ifelse"><span style="color: #003399; font-weight: bold;">ifelse</span></a><span style="color: #009900;">(</span>pcsar > <span style="color: #cc66cc;">.5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/ifelse"><span style="color: #003399; font-weight: bold;">ifelse</span></a><span style="color: #009900;">(</span>pcsar > <span style="color: #cc66cc;">.5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> alpha<span style="color: #009900;">)</span></pre>
<br />
Il n'y aura rien de nouveau au niveau du graphique géographique par rapport au post précédent, à part que l'on affiche des points et non des polygones. On superposera aussi le trait de côte. <br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/plot"><span style="color: #003399; font-weight: bold;">plot</span></a><span style="color: #009900;">(</span>comm2.ctrd<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=cols<span style="color: #339933;">,</span> pch=<span style="color: #cc66cc;">16</span><span style="color: #339933;">,</span> cex=<span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> xlim=<a href="http://inside-r.org/packages/cran/BB">bb</a><span style="color: #009900;">[</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #009900;">]</span><span style="color: #339933;">,</span> ylim=<a href="http://inside-r.org/packages/cran/BB">bb</a><span style="color: #009900;">[</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span>
<a href="http://inside-r.org/r-doc/graphics/plot"><span style="color: #003399; font-weight: bold;">plot</span></a><span style="color: #009900;">(</span>tc<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=<span style="color: blue;">"white"</span><span style="color: #339933;">,</span> lwd=<span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> add=<span style="color: black; font-weight: bold;">TRUE</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
C'est là, la partie nouvelle: à partir du data.frame appelé sobrement df, nous allons réaliser un plot x versus y assez standard. En x, nous aurons la distance séparant chaque commune de la côte, en y, la latitude et en couleur de point la nature du vote. Cette dernière sera donc la troisième dimension de ce graphique. <br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/plot"><span style="color: #003399; font-weight: bold;">plot</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/stats/dist"><span style="color: #003399; font-weight: bold;">dist</span></a><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/stats/df"><span style="color: #003399; font-weight: bold;">df</span></a>$y<span style="color: #339933;">,</span> pch=<span style="color: #cc66cc;">16</span><span style="color: #339933;">,</span> cex=<span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=cols<span style="color: #339933;">,</span> xlab=<span style="color: black; font-weight: bold;">NA</span><span style="color: #339933;">,</span> ylab=<span style="color: black; font-weight: bold;">NA</span><span style="color: #339933;">,</span> axes=<span style="color: black; font-weight: bold;">FALSE</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
Le paramètre graphique par(mfrow=c(1,2)) a permis de mettre côte à côte le graphique géographique et le graphique xy. <br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/par"><span style="color: #003399; font-weight: bold;">par</span></a><span style="color: #009900;">(</span>mfrow=<a href="http://inside-r.org/r-doc/base/c"><span style="color: #003399; font-weight: bold;">c</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> bg=<span style="color: blue;">"black"</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
J'ai choisi de représenter les traits de la même couleur afin de pouvoir faire la relation entre les deux. En quelque sorte, pour aboutir au second graphique. C'est comme si on prenait la France et qu'on la dépliait, l'étendait selon son littoral.<br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/abline"><span style="color: #003399; font-weight: bold;">abline</span></a><span style="color: #009900;">(</span>v=<span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=<span style="color: blue;">"white"</span><span style="color: #339933;">,</span> lwd=<span style="color: #cc66cc;">4</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha1YKISTWw1_UT3BaM7jg434kzGPwT1_gbTsmmQ-PtzMWJK5ow3af4VtqgWTkxO7q85d800udP4MzGWrixcqoKXWLxY4xWqq0nfnYGlr4rA1l2IBMuZ6U4sBK7qWwVkIEZQ7u2y5lsDKM/s1600/evolution.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="253" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha1YKISTWw1_UT3BaM7jg434kzGPwT1_gbTsmmQ-PtzMWJK5ow3af4VtqgWTkxO7q85d800udP4MzGWrixcqoKXWLxY4xWqq0nfnYGlr4rA1l2IBMuZ6U4sBK7qWwVkIEZQ7u2y5lsDKM/s320/evolution.png" width="320" /></a></div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYRgcAe_FwTorF1DNwyIx_VNQRiMmLq05DmjYQjJe4yg9YTfjkQK2_RdNQw8wEelHFxJRC8Ykf-XmTRt8K7y9ScVBhGPv2xoIIXhXOEGJ1mx6MrhtfpEahnF1lsKnVQx7Z4EmKIcdVriQ/s1600/test.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYRgcAe_FwTorF1DNwyIx_VNQRiMmLq05DmjYQjJe4yg9YTfjkQK2_RdNQw8wEelHFxJRC8Ykf-XmTRt8K7y9ScVBhGPv2xoIIXhXOEGJ1mx6MrhtfpEahnF1lsKnVQx7Z4EmKIcdVriQ/s640/test.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Nature du vote et distance au littoral</td></tr>
</tbody></table>
<br />
Intéressant ou pas, à vous de voir! En tout cas, nous avons pu voir quelques fonctions bien sympathiques!<br />
<pre class="r geshifilter-R" style="font-family: monospace;"><span style="color: #009900;"> </span></pre>
<pre class="r geshifilter-R" style="font-family: monospace;"><span style="color: #009900;"> </span></pre>harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-91254687040391244992012-05-13T19:00:00.000-07:002012-06-02T00:57:31.954-07:00Résultats du second tour: ma première choroplèthe avec R<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZfunZpXsTRlJD7S2E27JBvBGzziGSEkpEktyeEWO90wVGOD-GNvgEh-ST6iWQTrF-LETx5rzvcT_Hm8Jlb7bRF8AJx5RhKhCewkhAF2efk2yxcGsnMHmxa6G8Nh9hCU74zDow-HRLvog/s1600/jointure.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK2KjU1egsKbhFUAjhFOECQKEeggG8XJFjOk0dw-w54vac7oZF4YOOzP_j4bWUQfF74PAxUqfAfPrYLEGkauVtpn8bha4-H4j33u58wuxqixHfRsBQpJ57aazWx08LebFCakGWrRkGaCg/s1600/Rplot01.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="196" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjK2KjU1egsKbhFUAjhFOECQKEeggG8XJFjOk0dw-w54vac7oZF4YOOzP_j4bWUQfF74PAxUqfAfPrYLEGkauVtpn8bha4-H4j33u58wuxqixHfRsBQpJ57aazWx08LebFCakGWrRkGaCg/s200/Rplot01.png" width="200" /></a></div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-s-2tRCIPtCXTKJ_86JB7Ri9APRgRnILf4xfliaUqWuUM76iYSte2KaUXcsWxcCFabEzGEnjyxHZdnyYLYePg4IeUDNMhwuyqBrnyUx4JYzEJjsejHVjxwtOHIp5N_-pDMGLQHUHgFSY/s1600/Rplot01.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><br />
<div style="text-align: right;">
<span style="background-color: #fce5cd;"> article en français</span></div>
<br />
<b>French elections - my first choropleth with R</b> : Many journalists say that the electoral campaigns are becoming "data campaigns". The candidates are fighting, making massive use of numbers. They're looking for the number that will make the other one wrong. They're speaking numbers, displaying plots, graphics - interactive or not - about what the actual state of the country is, and how they intend to change it. Why not taking the most of the elections data to learn how to make a simple choropleth with <a href="http://www.r-project.org/" target="_blank">R</a>?<br />
<br />
<i>The entire code is available for download at the end of the article</i><br />
<br />
<br />
Dans cet article, nous allons créer une petite choroplèthe des résultats du second tour des élections présidentielles.<br />
<a name='more'></a><br />
Voici les adresses de téléchargement des fichiers source:<br />
- Contours des communes : <a href="http://professionnels.ign.fr/ficheProduitCMS.do?idDoc=6185461">http://professionnels.ign.fr/ficheProduitCMS.do?idDoc=6185461</a><br />
- Résultats des élections : <a href="http://www.data-publica.com/opendata/13495--resultats-du-deuxieme-tour-de-l-election-presidentielle-2012">http://www.data-publica.com/opendata/13495--resultats-du-deuxieme-tour-de-l-election-presidentielle-2012</a> <br />
<br />
Dans un premier temps, nous avons besoin d'installer les paquets appropriés: <a href="http://cran.r-project.org/web/packages/rgdal/index.html" target="_blank">rgdal</a> pour lire les données au format ESRI et <a href="http://cran.r-project.org/web/packages/maptools/index.html" target="_blank">maptools</a> pour certains traitements associés aux données géographiques.<br />
<br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/utils/install.packages"><span style="color: #003399; font-weight: bold;">install.packages</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/c"><span style="color: #003399; font-weight: bold;">c</span></a><span style="color: #009900;">(</span><span style="color: blue;">"rgdal"</span><span style="color: #339933;">,</span> <span style="color: blue;">"maptools"</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
Puis, nous importons, d'un côté les contours des communes de GEOFLA: <br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;">comm <- readOGR<span style="color: #009900;">(</span><span style="color: blue;">"F:/DATAS/GEOFLA/COMMUNES/COMMUNE.SHP"</span><span style="color: #339933;">,</span> <span style="color: blue;">"COMMUNE"</span><span style="color: #009900;">)</span></pre>
</div>
</div>
<br />
et le fichier du résultat du second tour des élections présidentielles.<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">votes <- <a href="http://inside-r.org/r-doc/utils/read.csv2"><span style="color: #003399; font-weight: bold;">read.csv2</span></a><span style="color: #009900;">(</span><span style="color: blue;">"IN/resultats2012.csv"</span><span style="color: #339933;">,</span> sep=<span style="color: blue;">","</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/quote"><span style="color: #003399; font-weight: bold;">quote</span></a>=<span style="color: blue;">"<span style="color: #000099; font-weight: bold;">\"</span>"</span><span style="color: #009900;">)</span></pre>
<br />
Le fichier des votes contient plusieurs colonnes. Pour les afficher:<br />
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;"><a href="http://inside-r.org/r-doc/base/names"><span style="color: #003399; font-weight: bold;">names</span></a><span style="color: #009900;">(</span>votes<span style="color: #009900;">)</span></pre>
<pre class="r geshifilter-R" style="font-family: monospace;"><span style="color: #009900;"></span></pre>
<br />
Calculons le pourcentage de votants par parti:</div>
<div class="geshifilter">
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">votes$pc.sar <- votes$results.sarkozy / votes$results.exprimes
votes$pc.hol <- votes$results.hollande / votes$results.exprimes</pre>
</div>
<div class="geshifilter">
On peut d'ores et déjà afficher quelques statistiques:</div>
</div>
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;"><a href="http://inside-r.org/r-doc/base/summary"><span style="color: #003399; font-weight: bold;">summary</span></a><span style="color: #009900;">(</span>votes$pc.sar<span style="color: #009900;">)</span></pre>
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;"><a href="http://inside-r.org/r-doc/base/summary"><span style="color: #003399; font-weight: bold;">summary</span></a><span style="color: #009900;">(</span>votes$pc.hol<span style="color: #009900;">)</span></pre>
<pre class="r geshifilter-R" style="font-family: monospace;"><span style="color: #009900;"> </span></pre>
</div>
</div>
Retenons uniquement les communes pour lesquelles des résultats électoraux sont renseignés dans le fichier.<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">nmatch <- <a href="http://inside-r.org/r-doc/base/which"><span style="color: #003399; font-weight: bold;">which</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/is.na"><span style="color: #003399; font-weight: bold;">is.na</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/base/match"><span style="color: #003399; font-weight: bold;">match</span></a><span style="color: #009900;">(</span>comm@data$INSEE_COM<span style="color: #339933;">,</span> votes$commune.code<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
<a href="http://inside-r.org/r-doc/base/print"><span style="color: #003399; font-weight: bold;">print</span></a><span style="color: #009900;">(</span>comm@<a href="http://inside-r.org/r-doc/utils/data"><span style="color: #003399; font-weight: bold;">data</span></a><span style="color: #009900;">[</span>nmatch<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/c"><span style="color: #003399; font-weight: bold;">c</span></a><span style="color: #009900;">(</span><span style="color: blue;">"INSEE_COM"</span><span style="color: #339933;">,</span> <span style="color: blue;">"NOM_COMM"</span><span style="color: #009900;">)</span><span style="color: #009900;">]</span><span style="color: #009900;">)</span>
comm <- comm<span style="color: #009900;">[</span>-nmatch<span style="color: #339933;">,</span> <span style="color: #009900;">]</span></pre>
<br />
Et hop, la jointure:<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">m <- <a href="http://inside-r.org/r-doc/base/merge"><span style="color: #003399; font-weight: bold;">merge</span></a><span style="color: #009900;">(</span>comm@data<span style="color: #339933;">,</span> votes<span style="color: #339933;">,</span> by.x=<span style="color: blue;">"INSEE_COM"</span><span style="color: #339933;">,</span> by.y=<span style="color: blue;">"commune.code"</span><span style="color: #339933;">,</span> all.x=<span style="color: black; font-weight: bold;">TRUE</span><span style="color: #009900;">)</span></pre>
<br />
Il faut aussi affecter un nom unique à chaque ligne. Pour les objets géographiques, on utilise la fonction <a href="http://rss.acs.unt.edu/Rdoc/library/maptools/html/spChFIDs-methods.html" target="_blank">spChFIDs</a> et pour les data frames, <a href="http://stat.ethz.ch/R-manual/R-devel/library/base/html/row.names.html">row.names</a>. Affectons le numéro INSEE de la commune:<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">comm <- spChFIDs<span style="color: #009900;">(</span>comm<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/as.character"><span style="color: #003399; font-weight: bold;">as.character</span></a><span style="color: #009900;">(</span>comm$INSEE_COM<span style="color: #009900;">)</span><span style="color: #009900;">)</span>
<a href="http://inside-r.org/r-doc/base/rownames"><span style="color: #003399; font-weight: bold;">rownames</span></a><span style="color: #009900;">(</span>m<span style="color: #009900;">)</span> <- <a href="http://inside-r.org/r-doc/base/as.character"><span style="color: #003399; font-weight: bold;">as.character</span></a><span style="color: #009900;">(</span>m$INSEE_COM<span style="color: #009900;">)</span></pre>
<br />
Maintenant, on peut aboutir à un nouvel objet géographique muni des résultats des élections.<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">comm2 <- SpatialPolygonsDataFrame<span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/methods/as"><span style="color: #003399; font-weight: bold;">as</span></a><span style="color: #009900;">(</span>comm<span style="color: #339933;">,</span> <span style="color: blue;">"SpatialPolygons"</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/utils/data"><span style="color: #003399; font-weight: bold;">data</span></a>=m<span style="color: #009900;">)</span></pre>
<br />
Voici un petit diagramme qui schématise toutes les étapes:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZfunZpXsTRlJD7S2E27JBvBGzziGSEkpEktyeEWO90wVGOD-GNvgEh-ST6iWQTrF-LETx5rzvcT_Hm8Jlb7bRF8AJx5RhKhCewkhAF2efk2yxcGsnMHmxa6G8Nh9hCU74zDow-HRLvog/s1600/jointure.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="412" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZfunZpXsTRlJD7S2E27JBvBGzziGSEkpEktyeEWO90wVGOD-GNvgEh-ST6iWQTrF-LETx5rzvcT_Hm8Jlb7bRF8AJx5RhKhCewkhAF2efk2yxcGsnMHmxa6G8Nh9hCU74zDow-HRLvog/s640/jointure.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Effectuer une jointure avec R</td></tr>
</tbody></table>
<br />
Nous allons, dans la carte, créer 20 classes de valeurs à partir des pourcentages avec la fonction classIntervals<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">cls <- classIntervals<span style="color: #009900;">(</span>comm2$pc.sar<span style="color: #339933;">,</span> n=<span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span> style=<span style="color: blue;">"equal"</span><span style="color: #009900;">)</span></pre>
<br />
Notre palette de couleurs ira du <b style="color: red;">rouge </b>pour Mr Hollande au <b style="color: blue;">bleu</b>, pour Mr Sarkozy, mais en passant par un point d'arrêt: le blanc là où il n'y a pas d'affection particulière pour l'un ou l'autre des candidats (votes proches de 50%). Considérant cette palette à trois couleurs, nous retrouvons les couleurs de chaque valeur et classe de cette façon:<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">colcode <- findColours<span style="color: #009900;">(</span>cls<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/c"><span style="color: #003399; font-weight: bold;">c</span></a><span style="color: #009900;">(</span><span style="color: blue;">"red"</span><span style="color: #339933;">,</span> <span style="color: blue;">"white"</span><span style="color: #339933;">,</span> <span style="color: blue;">"blue"</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span></pre>
<br />
Affichons le résultat:<br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/plot"><span style="color: #003399; font-weight: bold;">plot</span></a><span style="color: #009900;">(</span>comm2<span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=colcode<span style="color: #339933;">,</span> border=<span style="color: black; font-weight: bold;">NA</span><span style="color: #009900;">)</span></pre>
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/title"><span style="color: #003399; font-weight: bold;">title</span></a><span style="color: #009900;">(</span>main=<span style="color: blue;">"résultats des élections présidentielles - second tour"</span><span style="color: #009900;">)</span><span style="color: #009900;"> </span></pre>
</div>
</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF_vC4tRIv-KwG-v6seh9PB57cRiyGSWNRDrLF8evV0c6ZgqQpK1zB5_EfuVu0W5qiV8UysRNgRmPpnp4bsXSGQpRLAn4y_DQYs_aMyiZ9HK1RR-9W863wYDhiUBQZ_yxB725QG9q7gGc/s1600/Rplot02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlp_uZJ9s3AKTmRpFrgThzaPFu8VeqVIzw6r-3NgbD0cZ3duZRNwPSe85zpHron38OKRAU7ml9Jg_JR2NCXYVz71ZPZ8shOHHu8ilhqpgDszgBFrFRFRUUNdcGJ1-LoARsRoqwMVc61XY/s1600/Rplot03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlp_uZJ9s3AKTmRpFrgThzaPFu8VeqVIzw6r-3NgbD0cZ3duZRNwPSe85zpHron38OKRAU7ml9Jg_JR2NCXYVz71ZPZ8shOHHu8ilhqpgDszgBFrFRFRUUNdcGJ1-LoARsRoqwMVc61XY/s640/Rplot03.png" width="636" /></a></div>
<br />
Cela pourrait être sympa de mettre les contours des régions en plus. Cela nous permettra de voir en même temps comment dissoudre des polygones en fonction d'une valeur. Les contours des régions n'existent pas dans GEOFLA mais on peut les créer à partir du fichier des départements. On le fait comme ceci:<br />
<pre class="r geshifilter-R" style="background-color: #eeeeee; font-family: monospace;">dep <- readOGR<span style="color: #009900;">(</span><span style="color: blue;">"F:/DATAS/GEOFLA/DEPARTEMENTS/DEPARTEMENT.SHP"</span><span style="color: #339933;">,</span> <span style="color: blue;">"DEPARTEMENT"</span><span style="color: #009900;">)</span>
reg <- <a href="http://inside-r.org/packages/cran/maptools">maptools</a>::unionSpatialPolygons<span style="color: #009900;">(</span>dep<span style="color: #339933;">,</span> dep$NOM_REGION<span style="color: #009900;">)</span></pre>
<pre class="r geshifilter-R" style="font-family: monospace;"><span style="color: #009900;"> </span></pre>
On ajoute les contours de régions en les convertissant vers des objets lignes. Dans le jargon spatial R, on parle de coercion et cela se fait avec la librairie maptools. On ajoute aussi les libellés des régions. Pour la transparence des contours et des libellés, on utilise le 4e argument de la fonction <a href="http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/rgb.html" target="_blank">rgb</a>.<br />
<div style="background-color: #eeeeee; overflow: auto;">
<div class="geshifilter">
<div style="overflow: auto;">
<div class="geshifilter">
<pre class="r geshifilter-R" style="font-family: monospace;"><a href="http://inside-r.org/r-doc/graphics/plot"><span style="color: #003399; font-weight: bold;">plot</span></a><span style="color: #009900;">(</span><a href="http://inside-r.org/r-doc/methods/as"><span style="color: #003399; font-weight: bold;">as</span></a><span style="color: #009900;">(</span>reg<span style="color: #339933;">,</span> <span style="color: blue;">"SpatialLines"</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=<a href="http://inside-r.org/r-doc/grDevices/rgb"><span style="color: #003399; font-weight: bold;">rgb</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">.2</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> lwd=<span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> add=T<span style="color: #009900;">)</span>
<a href="http://inside-r.org/r-doc/graphics/text"><span style="color: #003399; font-weight: bold;">text</span></a><span style="color: #009900;">(</span>coordinates<span style="color: #009900;">(</span>reg<span style="color: #009900;">)</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/labels"><span style="color: #003399; font-weight: bold;">labels</span></a>=<a href="http://inside-r.org/r-doc/base/row.names"><span style="color: #003399; font-weight: bold;">row.names</span></a><span style="color: #009900;">(</span>reg<span style="color: #009900;">)</span><span style="color: #339933;">,</span> cex=<span style="color: #cc66cc;">.5</span><span style="color: #339933;">,</span> <a href="http://inside-r.org/r-doc/base/col"><span style="color: #003399; font-weight: bold;">col</span></a>=<a href="http://inside-r.org/r-doc/grDevices/rgb"><span style="color: #003399; font-weight: bold;">rgb</span></a><span style="color: #009900;">(</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">.5</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>
<a href="http://inside-r.org/r-doc/graphics/title"><span style="color: #003399; font-weight: bold;">title</span></a><span style="color: #009900;">(</span>main=<span style="color: blue;">"résultats des élections présidentielles - second tour"</span><span style="color: #009900;">)<span id="goog_1631903472"></span><span id="goog_1631903473"></span></span></pre>
</div>
</div>
</div>
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCXlroPBf7Qyd3A1nIqmJV2cdAIPbMsGJKBeyx-HWBp2R8rsAgEifDKntw_iuRErdM2YkaQMPuNWBvDh-WgxvRvskJqIhS4RPUh5H8RfYIPZwQJHZCJ19OncNjoyKUrESqeODxP7evHwo/s1600/Rplot06.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCXlroPBf7Qyd3A1nIqmJV2cdAIPbMsGJKBeyx-HWBp2R8rsAgEifDKntw_iuRErdM2YkaQMPuNWBvDh-WgxvRvskJqIhS4RPUh5H8RfYIPZwQJHZCJ19OncNjoyKUrESqeODxP7evHwo/s640/Rplot06.png" width="640" /></a></div>
Dans le prochain post, nous verrons comment aboutir à une représentation de ce type, toujours pour les élections présidentielles<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://dsparks.wordpress.com/2011/10/24/isarithmic-maps-of-public-opinion-data/" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="360" src="http://dsparks.files.wordpress.com/2011/10/cces-2008-party-identification-black.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Carte isarithmique des élections selon David B. Sparks</td></tr>
</tbody></table>
<br />
<br />
<i>N'hésitez pas à poser vos questions dans l'espace des commentaires si vous rencontrez des difficultés!</i><br />
<br />
Le code entier<a href="https://gist.github.com/2857180" target="_blank"> https://gist.github.com/2857180</a><br />
<br />
<script src="https://gist.github.com/2857180.js?file=election_choropleth.R"></script><br />
<br />
<br />
<br />
<br />harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com2tag:blogger.com,1999:blog-9055497882207462476.post-52143802500618569722012-04-08T23:42:00.000-07:002012-05-23T05:17:29.577-07:00Le carroyage avec QGIS et le plugin QMarxan, c'est facile!<div>
<div style="text-align: right;">
<span style="background-color: #fce5cd;">Article en français </span></div>
<div style="text-align: right;">
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="color: #e69138; float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYLXrfAp0GVgw-gV6DSkT9lkCw0Ae0CArJwMiHZyqp4gSUbmhoTqi46YPP24d4okheZmJiADbfQJcfMf3R4CDPi1Hy7vV8mjEAK5ZXHVeBbyNTsWcPhg4HxyODudjH7zYi-0vbPPfMgUw/s1600/osmcomplet.jpeg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="89" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYLXrfAp0GVgw-gV6DSkT9lkCw0Ae0CArJwMiHZyqp4gSUbmhoTqi46YPP24d4okheZmJiADbfQJcfMf3R4CDPi1Hy7vV8mjEAK5ZXHVeBbyNTsWcPhg4HxyODudjH7zYi-0vbPPfMgUw/s320/osmcomplet.jpeg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 13px; text-align: center;">Gridding Paris with OpenStreetMap data</td></tr>
</tbody></table>
<div>
<div style="color: #e69138;">
<div style="text-align: justify;">
<span style="color: black;"><b>"Gridding for the dummies" ;) with Quantum GIS and QMarxan:</b> In this article, I explain the purpose of gridding, why it is such an efficient way to analyse data within a large community of actors. Actually, gridding can be considered as a transcription of the raster format to the vector one where one tile <=> one cell. Thanks to QMarxan, gridding with QGIS is really simple: you don't need any knowledge in PostGIS, GRASS and R to do it. That's what we'll see: in the end of the post, I detail how to constitute some gridded data through a case study aiming to process a building density analysis on the city of Paris.</span> <span style="color: black;">The article is in French, but the printscreens will be helpful for the understanding. </span></div>
</div>
</div>
</div>
<div style="color: #e69138;">
<span style="color: black;"><br /></span></div>
<div style="color: #e69138;">
<span style="color: black;">All the material used in this article is free: Quantum GIS, OpenStreetMap for the buildings and INSEE (equivalent of US Census) for the population data.</span> </div>
<div style="color: #e69138;">
<br /></div>
<a name='more'></a><div style="color: #e69138;">
<br /></div>
<div style="color: #e69138;">
<b>Maillage / Carroyage</b></div>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.certu-catalogue.fr/p3950/produit.html" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" src="http://georezo.net/blog/sigurba/files/2011/10/carroyage-219x300.jpg" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Guide du CERTU sur les traitements en carroyage</td></tr>
</tbody></table>
<br />
Le CERTU (<span class="st">Centre d'Etudes sur les Réseaux, les Transports, l'Urbanisme et les Constructions)</span> a publié l'année dernière un guide en téléchargement gratuit appelé <a href="http://www.certu-catalogue.fr/traitements-geomatiques-par-carreaux-pour-l-observation-des-territoires.html" target="_blank">Traitements géomatiques par carreaux pour l'observation des territoires</a> qui décrit, par le biais de cas d'étude, tout le potentiel que permet la constitution de données carroyées.<br />
<br />
Le carroyage est un mode de représentation des données vecteur par carreau. Il s'effectue en croisant d'un côté une grille (soit rectangulaire, soit hexagonale en nid d'abeilles) avec des données métier. La précision avec laquelle s'effectuera l'analyse sera alors relative au pas choisi pour la grille. Ce pas diffère selon l'échelle d'analyse.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.insee.fr/fr/themes/detail.asp?reg_id=0&ref_id=donnees-carroyees" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="297" src="http://www.insee.fr/fr/ppp/bases-de-donnees/donnees-detaillees/donnees-carroyees/img/dc_france_dom.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Densité d'habitants selon l'INSEE</td></tr>
</tbody></table>
<br />
On peut d'ores et déjà disposer de données carroyées sur Internet. C'est le cas des <a href="http://www.insee.fr/fr/themes/detail.asp?reg_id=0&ref_id=donnees-carroyees" target="_blank">données INSEE sur le nombre d'habitants</a> disponible en téléchargement avec un pas de 1 kilomètre sur la France entière et 200 mètres sur chaque région. Le <a href="http://inpn.mnhn.fr/telechargement/cartes-et-information-geographique" target="_blank">Muséum National d'Histoire Naturelle</a> propose, lui, une grille-type pour effectuer un calcul, par carreau de 5 ou 10km, du nombre d'espèces d'un certain type de plantes ou d'animaux. <a href="http://inspire-forum.jrc.ec.europa.eu/pg/pages/view/1814/geographical-grid-systems" target="_blank">Inspire</a> propose aussi des grilles-types.<br />
<br />
En quoi ce mode de visualisation est-il si intéressant?<br />
<br />
<br />
<b style="color: #e69138;">Potentiel du carroyage</b><br />
<br />
- Le format vecteur est généralement choisi comme base de traitements car les utilisateurs du SIG sont plus familiers de l'exploitation de ce format. Pourtant, parfois, les calculs sur raster sont plus appropriés. Le carroyage permet de transcrire au format
vectoriel des méthodes rasters. L'augmentation de la taille d'un carreau s'apparente à une augmentation de la résolution (rééchantillonnage). Il est tout à fait possible d'effectuer des dénombrements, de calculer des moyennes, des écarts-types au niveau de chaque carreau, ce qui s'apparente aux calculs focaux utilisés sur les rasters.<br />
<br />
- La transformation de données fines, précises sous la forme de carreaux permet de vulgariser la donnée, de la simplifier, en sorte. Les mailles obtenues peuvent être confrontées à la fois à un niveau spatial: un carreau par rapport à ses voisins (par ex. étude de clusters), de même que dans le temps: état d'un carreau dans un état antérieur et dans un état actuel (par ex. étude de l'évolution de la population). C'est un mode de visualisation efficace qui "élimine le bruit" et découpe le territoire en unités égales et comparables.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTMhJ1x0UBQ7vbjfjdizq9TuxP1R9D3n2LEJBaqgVmEmqSuCk9ocXKsAhh_Le2Fsd1o3uWdRxEyHOZNHMCas4X3_DNe81X1O4NGPm6TrXB6LBohTkjAzvmQKAWuqsdGoBJKo8U-18TUG8/s1600/raster+vs+vecteur.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="195" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTMhJ1x0UBQ7vbjfjdizq9TuxP1R9D3n2LEJBaqgVmEmqSuCk9ocXKsAhh_Le2Fsd1o3uWdRxEyHOZNHMCas4X3_DNe81X1O4NGPm6TrXB6LBohTkjAzvmQKAWuqsdGoBJKo8U-18TUG8/s320/raster+vs+vecteur.gif" width="320" /></a></div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrigJBDCYSdLcvhY4PGmwtBwBHEFiUMksoYyi4VoKEAwBO7yHXBusLGuq4_Dcz6N7AyG9SQpeOAXNeapPa0_Fd3oNvnYTqqAGInUrLZA6aXlUVwvmNzEovX-79DRgUEEGl_LdIsHm2CkI/s1600/raster+vs+vecteur.gif" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a><br />
- Une troisième raison qui en fait un support intéressant est la possibilité d'associer plusieurs dimensions aux carreaux, comme autant de colonnes et d'attributs. On pourra alors adjoindre à chaque carreau des valeurs issues de différents domaines: environnement, transport, habitat, et de différents types: quantitative, qualitative, ordinale. On pourra faire apparaître différentes thématiques sur les choroplèthes au gré des besoins. Cette multi-dimensionnalité est difficile à atteindre avec les rasters dans la mesure où les pixels ne peuvent être associés qu'à un nombre limité de valeurs, de plus, positives. Sous R, des objets appelés SpatialGridDataFrame et SpatialPixelsDataFrame permettent d'associer à chaque pixel de nombreux attributs, comme les formats vecteur, mais R est un outil complexe qui nécessite un certain temps de prise en main.<br />
<br />
- Cette multi-dimensionnalité montre bien que le carroyage peut être un support d'analyse partagé entre des thématiciens de différents métiers. Des urbanistes, des botanistes peuvent se servir d'une même grille comme support pour leurs calculs puis confronter
leurs analyses.<br />
<br />
En définitive, l'accessibilité, la simplification, la multi-dimensionnalité font du carroyage un support intéressant pour des analyses et des représentations de données partagées.<br />
<br />
<br />
<div style="color: #e69138;">
<b>Carroyage sous QGIS</b></div>
<br />
Sous Quantum GIS, le carroyage est à la portée de tout géomaticien. On peut en réaliser sans utiliser ni PostgreSQL, GRASS, ni R même si je ne saurais que vous conseiller de vous investir dans l'apprentissage de ces derniers.<br />
<br />
Nativement, on peut l'exécuter par le biais de la fonction "Création de Grille" puis "Points dans un Polygone" pour des cartes de densité. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjonVc36nVmNbC51VW-Bk8FK26Iae22oBKX9yAlRr62M1VcfKAdkIdeOmlZTd4xyKv3mKxnVmninBm4goYNUFLrTCJwWgIn_-_NdwjCyU9U_TIa3E_tD_OdBuHSxtX4U9rGzkJicm5WsW8/s1600/17-points+dans+un+polygone.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="337" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjonVc36nVmNbC51VW-Bk8FK26Iae22oBKX9yAlRr62M1VcfKAdkIdeOmlZTd4xyKv3mKxnVmninBm4goYNUFLrTCJwWgIn_-_NdwjCyU9U_TIa3E_tD_OdBuHSxtX4U9rGzkJicm5WsW8/s400/17-points+dans+un+polygone.jpeg" width="400" /></a></div>
<br />
Cependant, l'année dernière, un plugin est apparu sur le dépôt d'extension appelé <a href="http://www.aproposinfosystems.com/products/qmarxan/" target="_blank">QMarxan</a> qui permet d'aller plus loin. Il s'agit d'un plugin QGIS d'interfaçage avec le logiciel Marxan.<i> </i><br />
<i><br /></i><br />
Voici la définition que l'on trouve sur le site des parcs du Canada quant au logiciel <a href="http://www.pc.gc.ca/progs/amnc-nmca/cnamnc-cnnmca/dgs-ssg/itm3-/page2_f.asp" target="_blank">Marxan</a>:<br />
<i>"Marxan a été mis au point par des chercheurs de l'Université de
Queensland pour faciliter le rezonage du parc marin de la Grande
Barrière et a par la suite été utilisé un peu partout dans le monde dans
le cadre de projets de planification d'aires marines. Au moyen d'un
algorithme d'optimisation, ce programme sélectionne des séries de
secteurs qui permettent d'atteindre des objectifs de conservation tout
en réduisant au minimum les incidences socio-économiques sur les
utilisateurs des milieux marins et des collectivités côtières. Les
données qui y sont entrées peuvent comporter un large éventail
d'éléments/de valeurs liés aux aspects écologiques, socio-économiques,
culturels et à l'expérience du visiteur, y compris les espèces, les
habitats, les activités récréatives et les sites culturels."</i><br />
<br />
Dans cet article, nous n'exploiterons pas tout le potentiel du plugin. Nous verrons sa fonctionnalité principale, celle permettant de réaliser une grille et d'effectuer des calculs par carreau. Nous ne couvrirons pas l'exploitation des résultats sous Marxan.<br />
<br />
<br />
<b style="color: #e69138;">Le bâti en Île-de-France </b><br />
<br />
Le cas d'étude sera celui de l'analyse du bâti à Paris avec la constitution d'un carroyage décrivant la densité du bâti en terme de nombre et de surface de bâtiments. Puis, nous exploiterons le carroyage de l'INSEE afin de coupler les données concernant le bâti avec la population.<br />
<br />
<span style="color: #e69138;">Téléchargement des données</span><br />
<br />
Dans un premier temps, téléchargeons les limites administratives de la ville de Paris:<br />
<a href="http://export.openstreetmap.fr/contours-administratifs/export-communes/%20" target="_blank">http://export.openstreetmap.fr/contours-administratifs/export-communes/ </a><br />
<br />
Puis les données du bâti à partir du site GeoFabrik:<br />
<a href="http://download.geofabrik.de/osm/europe/france/ile-de-france.shp.zip">http://download.geofabrik.de/osm/europe/france/ile-de-france.shp.zip</a><br />
<br />
Effectuons une extraction des donnés sur la ville de Paris par le biais de l'extension "Requête Spatiale". Le temps de traitement est très long!..<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIs-3mb-qyZCoP2FuuESzbhkYe_n7HjazFytiEFhGkaG08in_BMgbiIqtFl7dajKl7C6cxNGAo_a9v92p2vEHK4Ad1aVlBUNYRHKWsbPxEjkPTQOVi82L-qAW9JLU9XugfFzMXzmOwp8s/s1600/1.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIs-3mb-qyZCoP2FuuESzbhkYe_n7HjazFytiEFhGkaG08in_BMgbiIqtFl7dajKl7C6cxNGAo_a9v92p2vEHK4Ad1aVlBUNYRHKWsbPxEjkPTQOVi82L-qAW9JLU9XugfFzMXzmOwp8s/s400/1.gif" width="232" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
Par la suite, les données bâtiments buildings seront transformées en Lambert 2 Etendu afin de les coupler par la suite (fin du tutoriel) avec les données INSEE qui sont dans ce système de projection. La couche transformée se nomme buildings_LA2E.<br />
<br />
Dans un premier temps, il faut installer l'extension QMarxan depuis les dépôts-tiers.<br />
<br />
<br />
<span style="color: #e69138;">Réalisation d'une grille en nid d'abeilles</span><br />
<br />
Une fois le plugin installé, lançons le module de génération de grille<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh93dt4jdZMLlV_QBfKXLKP6yHkHAIUkceI8553aMhFY1Cze14JFKqnIBPH900CgdjFo_TzmhChoQMQf-4Kx5BuwXOSeFGI8GKs9XlpNgfeDMXzk5Sm-GV-Hc41Zlyk1bxECGp89-g4k0Q/s1600/1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="215" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh93dt4jdZMLlV_QBfKXLKP6yHkHAIUkceI8553aMhFY1Cze14JFKqnIBPH900CgdjFo_TzmhChoQMQf-4Kx5BuwXOSeFGI8GKs9XlpNgfeDMXzk5Sm-GV-Hc41Zlyk1bxECGp89-g4k0Q/s400/1.gif" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwyH-MawY9ioa2z9xG1FqszeVKOHrpe_5AoT_e0l8fYK7dFdE3qEox4TyE1aR5JhSGrJunm6RH0fsICq1peeO5DG6DIzX0vBNQtvmCLGJBCMF7zDqDcKDw3xxHJC6WC8CgpBzXOwzZYGI/s1600/2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<br />
<br />
J'aime bien les grilles en nid d'abeilles qui sont assez esthétiques. Réalisons-en une. Nous choisirons un pas de 200 mètres comme pour l'INSEE.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeNGJHJtLW6pFIyoPWKFW4FH1Mzp5tlZnmdK_ZRHtpoYDVh0gnspRbNNy7_AvaSKM99oeSAGmpuLuj-9eOdwzoypFVHmTJN6S4ZTLEkFvfLwJyhA3jf4tjbBunGlFIUSAET36jE0c8IbA/s1600/1-create+planning.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeNGJHJtLW6pFIyoPWKFW4FH1Mzp5tlZnmdK_ZRHtpoYDVh0gnspRbNNy7_AvaSKM99oeSAGmpuLuj-9eOdwzoypFVHmTJN6S4ZTLEkFvfLwJyhA3jf4tjbBunGlFIUSAET36jE0c8IbA/s640/1-create+planning.gif" width="560" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Création d'une grille hexagonale sur la base du fichier de bâti</td></tr>
</tbody></table>
<br />
Voici le résultat du carroyage. Notre grille est pour l'instant vide de données statistiques sur le bâti.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXYrsesJi3luPago3oWQFydxf4RCP9NbAjP0qMIC2m7niIQXWkH0SAjZO9SnDFIcwqsEDFk7DAX39QX7pARucXzWvroRU80K09a6Pc7oTM2y90xEdu07O4Ue_3r1g3wM7svT1g80sv5NI/s1600/2-affichage.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="337" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXYrsesJi3luPago3oWQFydxf4RCP9NbAjP0qMIC2m7niIQXWkH0SAjZO9SnDFIcwqsEDFk7DAX39QX7pARucXzWvroRU80K09a6Pc7oTM2y90xEdu07O4Ue_3r1g3wM7svT1g80sv5NI/s640/2-affichage.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Bâti + grille en nid d'abeilles</td></tr>
</tbody></table>
<br />
<br />
<span style="color: #e69138;">Calcul de la surface, du nombre de bâtiments et de la surface moyenne par carreau</span><br />
<br />
Effectuons le calcul de la surface de bâti par carreau.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwyH-MawY9ioa2z9xG1FqszeVKOHrpe_5AoT_e0l8fYK7dFdE3qEox4TyE1aR5JhSGrJunm6RH0fsICq1peeO5DG6DIzX0vBNQtvmCLGJBCMF7zDqDcKDw3xxHJC6WC8CgpBzXOwzZYGI/s1600/2.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwyH-MawY9ioa2z9xG1FqszeVKOHrpe_5AoT_e0l8fYK7dFdE3qEox4TyE1aR5JhSGrJunm6RH0fsICq1peeO5DG6DIzX0vBNQtvmCLGJBCMF7zDqDcKDw3xxHJC6WC8CgpBzXOwzZYGI/s400/2.gif" width="400" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiB6oI_P5twsN1Kr85YWF0nJx01bi8P39BSusHfHb4YkfmzAQ7Ac5ubE4zxZj2qizweOAIyQnzIZkHXnrE-N-MdhGeAQK0V-CzW8yFycjax4o9hQou9uYI2rGigBFeGLbXPy7Jr6UPTYc/s1600/3-area_build.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="380" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiB6oI_P5twsN1Kr85YWF0nJx01bi8P39BSusHfHb4YkfmzAQ7Ac5ubE4zxZj2qizweOAIyQnzIZkHXnrE-N-MdhGeAQK0V-CzW8yFycjax4o9hQou9uYI2rGigBFeGLbXPy7Jr6UPTYc/s400/3-area_build.gif" width="400" /></a></div>
<br />
Le résultat est intégré à la grille:<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiytuXNFGVQLaFYoA_G_3JtGL3FniupO_pi4RXCmbOvitlcuF2VjU7VRZ_UXDR413m307pXn2EkOIHoKe39tevjwrL7y3s_86ZxCqlGWn3dAeWzfX7qZD7vMnUq2FGht1Dck1ISa2prPKs/s1600/4-results.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="488" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiytuXNFGVQLaFYoA_G_3JtGL3FniupO_pi4RXCmbOvitlcuF2VjU7VRZ_UXDR413m307pXn2EkOIHoKe39tevjwrL7y3s_86ZxCqlGWn3dAeWzfX7qZD7vMnUq2FGht1Dck1ISa2prPKs/s640/4-results.gif" width="640" /></a> <br />
<br />
Afin d'avoir une bonne visualisation de l'ensemble, nous avons extrait les nids d'abeille comportant une surface supérieure à 0:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3ofNuqJZXcX7Nm5o9ocPEotJgi8BHSbCVU1VGzt50HzJNhdxlI6PGSkAMyx7Hbp6XVjJyJS6cF2_XRG2YNtas99xOGaT8k0CpsMwk6DRvr7kc7pTnmMWhgeTZVuq3XuZFOw6DG1xlqVs/s1600/5-results.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="561" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3ofNuqJZXcX7Nm5o9ocPEotJgi8BHSbCVU1VGzt50HzJNhdxlI6PGSkAMyx7Hbp6XVjJyJS6cF2_XRG2YNtas99xOGaT8k0CpsMwk6DRvr7kc7pTnmMWhgeTZVuq3XuZFOw6DG1xlqVs/s640/5-results.gif" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp8Fn8YSXIZHe6MWDW8ZX-TZSpmlq__YGUfjYveMyba2dUAwctiQ7xfYh-2fBeunzLKpCe8DfDDtq_CkIfxgDX_kkp7ixT-9DKiGtle4SxsKgcW-N52CeevjCYttx2Rvx6uVus6tALEcI/s1600/6-carte.gif" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp8Fn8YSXIZHe6MWDW8ZX-TZSpmlq__YGUfjYveMyba2dUAwctiQ7xfYh-2fBeunzLKpCe8DfDDtq_CkIfxgDX_kkp7ixT-9DKiGtle4SxsKgcW-N52CeevjCYttx2Rvx6uVus6tALEcI/s1600/6-carte.gif" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp8Fn8YSXIZHe6MWDW8ZX-TZSpmlq__YGUfjYveMyba2dUAwctiQ7xfYh-2fBeunzLKpCe8DfDDtq_CkIfxgDX_kkp7ixT-9DKiGtle4SxsKgcW-N52CeevjCYttx2Rvx6uVus6tALEcI/s1600/6-carte.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp8Fn8YSXIZHe6MWDW8ZX-TZSpmlq__YGUfjYveMyba2dUAwctiQ7xfYh-2fBeunzLKpCe8DfDDtq_CkIfxgDX_kkp7ixT-9DKiGtle4SxsKgcW-N52CeevjCYttx2Rvx6uVus6tALEcI/s320/6-carte.gif" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Surface de bâti en 10 classes selon la méthode de Jenks</td></tr>
</tbody></table>
<br />
Pour avoir le nombre de bâtiments par carreau, on doit tout d'abord générer une couche de points. Nous l'appellerons buildings_ct<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKSuoeUWI8D5qebMYDgHVIs3HPF5CnviqhDZPZWIODnXqI_uaPu3JeBGeQ3xEH8zEQvkKuIBybZxpEdoOlkebsCcysxm-SCffprMPkae-A1Yz5n0xtAogGV-OLxTvEvk4CysGkHLCfAUM/s1600/7-centroides.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="132" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKSuoeUWI8D5qebMYDgHVIs3HPF5CnviqhDZPZWIODnXqI_uaPu3JeBGeQ3xEH8zEQvkKuIBybZxpEdoOlkebsCcysxm-SCffprMPkae-A1Yz5n0xtAogGV-OLxTvEvk4CysGkHLCfAUM/s400/7-centroides.gif" width="400" /></a></div>
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjkMcqYQKLEo-A8BHxjDl_9utCEhSt-rbdERjlETmtMv5zVCzi1R4knbA1gSJP7WAwHN0_BqQW1z2zxa5jgO4cRvMSRnSzLpLF6IC4v4Ii-u8UAidutFwP7l4dP7kY7mOtOM5R20Wf7c0/s1600/8-centoides.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="251" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjkMcqYQKLEo-A8BHxjDl_9utCEhSt-rbdERjlETmtMv5zVCzi1R4knbA1gSJP7WAwHN0_BqQW1z2zxa5jgO4cRvMSRnSzLpLF6IC4v4Ii-u8UAidutFwP7l4dP7kY7mOtOM5R20Wf7c0/s400/8-centoides.gif" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Centroïdes des bâtiments superposés sur la surface bâtie</td></tr>
</tbody></table>
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglIcCI3QeXQ_go0EqXAcdV1HuW5wQeqK5QTbCbn7Q0u5pjfQY1Li8u4tGQOJukXpgPynsR2sSSOw8cSdsHYoz32zKClua4z_PWmJ8clmWIebpiMz6E4mIxVyzj3lSW3GuosLdxeY9iBAk/s1600/9-nbpoitns.gif" style="margin-left: 1em; margin-right: 1em;"></a> <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglIcCI3QeXQ_go0EqXAcdV1HuW5wQeqK5QTbCbn7Q0u5pjfQY1Li8u4tGQOJukXpgPynsR2sSSOw8cSdsHYoz32zKClua4z_PWmJ8clmWIebpiMz6E4mIxVyzj3lSW3GuosLdxeY9iBAk/s1600/9-nbpoitns.gif" style="margin-left: 1em; margin-right: 1em;"></a> <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglIcCI3QeXQ_go0EqXAcdV1HuW5wQeqK5QTbCbn7Q0u5pjfQY1Li8u4tGQOJukXpgPynsR2sSSOw8cSdsHYoz32zKClua4z_PWmJ8clmWIebpiMz6E4mIxVyzj3lSW3GuosLdxeY9iBAk/s1600/9-nbpoitns.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="380" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglIcCI3QeXQ_go0EqXAcdV1HuW5wQeqK5QTbCbn7Q0u5pjfQY1Li8u4tGQOJukXpgPynsR2sSSOw8cSdsHYoz32zKClua4z_PWmJ8clmWIebpiMz6E4mIxVyzj3lSW3GuosLdxeY9iBAk/s400/9-nbpoitns.gif" width="400" /></a></div>
<br />
Le nombre de bâtiments par carreau peut être indicatif d'un type de bâti: collectif, résidentiel, etc...<br />
<br />
Nous pouvons calculer la surface moyenne de bâti par carreau: surface/(nombre de bâtiments) <br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRPHc2W2ffJoxgn8dSjh60KB156AUvXvjxmPb3M_sgqlJHqlj1Ko9M-j4f4a35k8YImRBAK-T8ekn_iW600FBunLzRC_jbEmU19RYA2vfpwOEJ6EM_McKV0as71IYFxKVa9kt1dKSJ2rQ/s1600/10-surfmoy.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="523" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRPHc2W2ffJoxgn8dSjh60KB156AUvXvjxmPb3M_sgqlJHqlj1Ko9M-j4f4a35k8YImRBAK-T8ekn_iW600FBunLzRC_jbEmU19RYA2vfpwOEJ6EM_McKV0as71IYFxKVa9kt1dKSJ2rQ/s640/10-surfmoy.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Utilisation de la calculatrice de champ</td></tr>
</tbody></table>
<br />
Voici différentes choroplèthes obtenues en superposant le résultat du carroyage avec les données <a href="http://openstreetmap.fr/" target="_blank">OpenStreetMap</a> grâce au <a href="http://spatialgalaxy.net/2012/01/14/qgis-plugin-of-the-week-openlayers/" target="_blank">plugin OpenLayers</a> de QGIS.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="https://picasaweb.google.com/lh/photo/ZgTY9ShcGNgmE0e5WHrSVMMgbHW51AOnNtzKTxSCN0c?feat=directlink" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYLXrfAp0GVgw-gV6DSkT9lkCw0Ae0CArJwMiHZyqp4gSUbmhoTqi46YPP24d4okheZmJiADbfQJcfMf3R4CDPi1Hy7vV8mjEAK5ZXHVeBbyNTsWcPhg4HxyODudjH7zYi-0vbPPfMgUw/s640/osmcomplet.jpeg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 13px;">Nombre de bâtiments, surface de bâti et surface moyenne sur couches OpenStreetMap Paris</td></tr>
</tbody></table>
<div>
<div style="text-align: right;">
<br />
<div style="text-align: left;">
<span style="color: #e69138;">Couplage données nombre d'habitants et bâti sur la base d'une grille pré-existante</span></div>
</div>
</div>
On peut aussi lancer les calculs en se basant sur une grille autre, par exemple celle de l'INSEE, et ensuite coupler les données habitants et bâti.<br />
<br />
Les zones d'activité pourraient ainsi apparaître comme des zones de bâti comprenant peu d'habitants. <br />
<br />
Téléchargeons le carroyage de l'INSEE qui se trouve en Lambert 2 Etendu. Il contient les estimations du nombre d'habitants. Un préalable, comme au départ, est de ne prendre que les carreaux situés sur Paris.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMor1Z2jU0XzJ6RDDuLquNO7boRdApXJ2ieTSbMUBevd1NyK-_3fpPHmDYDXownTEIkCxsOrnncxchxvKvsC3btK5zCxEzpHOV3PUOntcCfX8UjQoVsrrTz7zJaEjgHT6XKhkDdFShibA/s1600/12-insee+paris.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMor1Z2jU0XzJ6RDDuLquNO7boRdApXJ2ieTSbMUBevd1NyK-_3fpPHmDYDXownTEIkCxsOrnncxchxvKvsC3btK5zCxEzpHOV3PUOntcCfX8UjQoVsrrTz7zJaEjgHT6XKhkDdFShibA/s320/12-insee+paris.gif" width="187" /></a></div>
<br />
Associons ces données du bâti avec ces données de population en utilisant le carroyage existant:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGucsILf-mG5a4w8GIOb1FMITQh3ehgqM7voAuIKJJIAYegMcfs-DFB3RP-vzmOj24ZFhSmdohEzl4BSQJ2495bi9om3X0b0PD4T29d2GhXpXdOQduZN4ej38GPxr5Mes1DaXIosqRocs/s1600/14-calcul.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGucsILf-mG5a4w8GIOb1FMITQh3ehgqM7voAuIKJJIAYegMcfs-DFB3RP-vzmOj24ZFhSmdohEzl4BSQJ2495bi9om3X0b0PD4T29d2GhXpXdOQduZN4ej38GPxr5Mes1DaXIosqRocs/s640/14-calcul.gif" width="530" /></a></div>
<br />
Le résultat est alors intégré dans la grille de l'INSEE:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixlEaWkpd2lIFfHBAAfz1aulBvmRkXgg2frAR9bnufEsOTKvZWOdd-gRkwPyJ68LSgTHXGHi5qZNF0gribafIZ1cV_T9JcJOMFbTJ-CqzXzY0Rllyc9qUeWOIxckf4-q-qb2i7whrfCpU/s1600/15-results.gif" style="margin-left: auto; margin-right: auto;"><img border="0" height="488" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixlEaWkpd2lIFfHBAAfz1aulBvmRkXgg2frAR9bnufEsOTKvZWOdd-gRkwPyJ68LSgTHXGHi5qZNF0gribafIZ1cV_T9JcJOMFbTJ-CqzXzY0Rllyc9qUeWOIxckf4-q-qb2i7whrfCpU/s640/15-results.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">ajout de la colonne area_built au carroyage de l'INSEE</td></tr>
</tbody></table>
<br />
Ouvrons le fichier dbf issu du carroyage sous OpenOffice, enregitrons-le au format ods et réalisons un graphique bivarié avec en abcisse la surface de bâtiments et en ordonnée le nombre d'habitants.<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzR2Z018B1X_f0eCCZ_4_8r19E3-KQ0JbpzhrosEqh7WgAaa0vJqppwUZ4KHfjFVSW-Jy3WdAO4RIchpn8igEce4ESuHA1ocRYRh-xP79ns6YZzuIHlJIOfwGiW0cM-q2Y78kqwNI2bc0/s1600/16-gaphique.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="386" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzR2Z018B1X_f0eCCZ_4_8r19E3-KQ0JbpzhrosEqh7WgAaa0vJqppwUZ4KHfjFVSW-Jy3WdAO4RIchpn8igEce4ESuHA1ocRYRh-xP79ns6YZzuIHlJIOfwGiW0cM-q2Y78kqwNI2bc0/s400/16-gaphique.gif" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">fichier ods obtenu à partir du dbf</td></tr>
</tbody></table>
Nous pouvons voir quelle relation existe entre le
nombre d'habitants et la surface de bâti, ainsi qu'identifier des
carreaux qui échappent à la tendance principale.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGNrt3keoJQOBMam8f5jl30W9j7VZXWdIkesN45pg0GJD-KWAYA3m-xRWKRsFniMUHOQz4qFWWGbFh3RTEb5ouKzdFZHUQYKBx_3Cj3YCKlvqk7uPwWSTqQrKpAFR98ghU6OMEkBInTu4/s1600/17-graphique.gif" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="342" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGNrt3keoJQOBMam8f5jl30W9j7VZXWdIkesN45pg0GJD-KWAYA3m-xRWKRsFniMUHOQz4qFWWGbFh3RTEb5ouKzdFZHUQYKBx_3Cj3YCKlvqk7uPwWSTqQrKpAFR98ghU6OMEkBInTu4/s640/17-graphique.gif" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Identification d'un point échappant à la "tendance"</td></tr>
</tbody></table>
<br />
<b>Remarque:</b> A vrai dire, il est difficile de dégager une quelconque tendance à partir de ce graphique car dans le cas du bâti, la surface moyenne ne suffit pas à prédire le nombre d'habitants. Il faut aussi intégrer la hauteur du bâtiment ou son nombre d'étages. Cela dit, le but de cet exemple est de montrer comment le carroyage permet de confronter deux (voire plus) variables de manière efficace par le biais d'une analyse bivariée (ou multi-variée).<br />
<br />
<i><br /></i><br />
<i><b> Nota Bene:</b> dans la première version de QMarxan,
l'utilisation de grilles rectangulaires génère des erreurs. Aussi la
dernière version a-t-elle été utilisée pour l'intégration des
informations du bâti dans le carroyage de l'INSEE.</i><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.r-project.org/" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;" target="_blank"><img border="0" src="http://www.r-project.org/Rlogo.jpg" /></a></div>
Pour ceux qui souhaitent aller plus loin dans le carroyage, je vous conseille d'utiliser <a href="http://www.r-project.org/" target="_blank">R</a> avec la librairie sp. La fonction over( ) permet de croiser dans n'importe quel ordre des données vectorielles et rasters ainsi que d'effectuer une infinité de calculs à l'intérieur de chaque carreau, ceci grâce à une fonction personnelle fn: over(x, y, returnList = FALSE, fn = NULL, ...). On peut alors envisager de calculer l'écart-type ou même l'indice écologique de diversité de Shannon. Absolument tout est possible!<br />
Plus d'infos sur les méthodes d'agrégation spatiale avec R ici: <a href="http://cran.r-project.org/web/packages/sp/vignettes/over.pdf">http://cran.r-project.org/web/packages/sp/vignettes/over.pdf</a><br />
<br />
<br />
<br />
<br />harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com7tag:blogger.com,1999:blog-9055497882207462476.post-42397890443863575072012-03-12T00:56:00.000-07:002013-02-06T06:11:20.988-08:00Archipels de prospérité<div style="text-align: right;">
<span style="background-color: #fce5cd;">Article en français</span><br />
<span style="background-color: #fce5cd;"><br /></span></div>
<div style="text-align: right;">
<a href="http://www.flickr.com/photos/10519370@N04/6815192034/" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;" target="_blank" title="archipels de prospérité de mathieu rajerison, sur Flickr"><img alt="archipels de prospérité" height="200" src="http://farm8.staticflickr.com/7188/6815192034_3fb85bf8a8.jpg" style="border-style: none; border-width: medium;" width="200" /></a><br />
<div style="text-align: justify;">
<b style="font-weight: bold;">Archipelagos of Prosperity</b><b> test: </b>Previously, I had mentioned <a href="http://coulmont.com/blog/2011/12/11/ah-36-000-communes/" target="_blank">a map of prosperity in France</a>
that created a buzz amongst the R community. Following the idea of
mapping sociological indicators, I tested a few ways of mixing ordinal
and geographical visualizations in these posts (the <a href="http://datagistips.blogspot.com/2012/01/autre-proposition-de-representation.html" target="_blank">1st</a> and the <a href="http://datagistips.blogspot.com/2012/01/une-petite-carte-socio-niveau-de-vie.html" target="_blank">2nd</a>).
Prosperity is an actual topic in our period of crisis. I imagined a way
of representig prosperity on a map, besides the choropleth and the <a href="http://www.joelgombin.fr/?p=577" target="_blank">cartogram</a>. For the creation below, I took inspiration <a href="https://shop.gestalten.com/index.php/catalog/product/view/id/160" target="_blank">on a book cover</a>
that figured a chart as a fictive landscape and based on my observation
of islands of prosperity on Coulmont's map, I imagined France as an
oniric landscape made of archipelagos, lagoons. This exotic vision
contrasts with the toughness of the subject.</div>
</div>
<br />
<a name='more'></a><br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://coulmont.com/blog/2011/12/11/ah-36-000-communes/" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="385" src="http://coulmont.com/vordpress/wp-content/uploads/2011/12/revenus-france.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Choroplèthe de la prospérité en France de Baptiste Coulmont</td></tr>
</tbody></table>
<br />
<br />
Je vous évoquais précédemment <a href="http://coulmont.com/blog/2011/12/11/ah-36-000-communes/" target="_blank">la carte de Baptiste Coulmont</a>
sur une représentation de la prospérité en France sous la forme de
choroplèthe. Parmi les aspects intéressants liés à cette carte, il me
semble qu'il s'agit surtout du côté granuleux qui donne un côté mosaïque
très fin. La qualité esthétique provient en grande partie du nombre de
communes considéré: 36000. Elle n'aurait pas été comparable si elle
avait intégré un nombre plus réduit d'entités, par exemple, les
départements. Aussi, elle fait apparaître une organisation spatiale de
la prospérité avec ce qui s'apparente à des îlots. <br />
<br />
La
quantité de données parvient sur cette carte, par le biais d'une simple
représentation, à faire apparaître un phénomène qui n'aurait pas
forcément été visible à
une échelle plus grossière. Cette carte est représentative du courant
"BigData" qui entoure le traitement de données très larges et que permet
les moyens techniques actuels: Hadoop, R, Processing,....<br />
<br />
On
voit de plus en plus de designers d'information formés à
la programmation qui s'emparent de ce type de données. Ces dernières
proviennent souvent de webservices délivrés par des sites de réseaux
sociaux: Twitter, Facebook, services en mesure de délivrer des millions
d'informations. Ces designers proposent parfois des visualisations
extrêmement inventives qui bousculent nos conventions. On peut citer par
exemple <a href="http://www.flickr.com/photos/walkingsf/" target="_blank">les cartes d'Eric Fischer</a> qui transforme des données issues du réseau social twitter en cartes d'une grande beauté.<br />
<br />
En
confrontant les référentiels, on joue sur la sensibilité du lecteur de
la carte et on l'incline à l'immersion. L'émotion peut jaillir d'une
représentation de données, qu'elle soit cartographique ou non. Des
artistes numériques ou des scientifiques font preuve d'imagination afin
de proposer des créations mémorables qui jouent avec nos sens. Des
scientifiques travaillant sur le Large Hadron Collider ont ainsi créé <a href="http://www.blogger.com/goog_637510185">u</a><a href="http://www.dailymail.co.uk/sciencetech/article-1343753/The-sound-particle-pings-Scientists-turn-Large-Hadron-Collider-data-music.html" target="_blank">ne musique à partir des données de l'accélérateur de particules Large Hadron Collider</a>. L'analyse n'est plus visuelle mais auditive. Inversement, <a href="http://blog.chenalexander.com/2011/baroque-bach-cello/" target="_blank">ce travail</a>
montre la transcription visuelle du prélude de Bach pour violoncelle.
Le mélange des genres, les combinaisons inattendues, la
transdisciplinarité constituent le terreau d'un certain renouveau dans
la représentation d'informations.<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://ecx.images-amazon.com/images/I/516P28GGo0L._SL500_AA300_.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://ecx.images-amazon.com/images/I/516P28GGo0L._SL500_AA300_.jpg" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Couverture du livre Data Flow 2</td></tr>
</tbody></table>
<br />
Un jour, alors que je m'intéressais à l'achat d'un livre sur le design d'information, je suis tombé sur ce livre appelé <a href="http://usshop.gestalten.com/data-flow-2-161.html" target="_blank">Data Flow.</a> La couverture de ce bouquin m'a fasciné car y figure un graphe de données traduit sous forme de paysage très réaliste.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.ingraphics.info/" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="http://www.ingraphics.info/wp-content/uploads/2011/11/ingraphics_teaser4.jpg" width="297" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Magazine In-graphic </td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.colorful-data.net/wp-content/uploads/ingraphics_produkt1.jpg" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
Plus
tard, je suis également tombé sur ce site présentant plusieus
couvertures, dont une où l'on voit plusieurs graphiques en ligne
transcrits sous la forme de sommets montagneux. <br />
<br />
Je me
suis alors dit que cette idée de paysage fictif pouvait être explorée
dans le cadre de cartographies statistiques. La carte de Baptiste
Coulmont fait apparaître des sortes d'îlots de prospérité. L'idée de
pouvoir réaliser un paysage insulaire sur la France
entière à partir des données de revenu par commune m'apparut une
tentative intéressante. Cela consisterait à traduire des indicateurs
sociologiques sous forme topographique et ainsi aboutir à une "carte
métaphorique". <br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.flickr.com/photos/10519370@N04/6815192034/" style="margin-left: 1em; margin-right: 1em;" target="_blank" title="archipels de prospérité de mathieu rajerison, sur Flickr"><img alt="archipels de prospérité" height="500" src="http://farm8.staticflickr.com/7188/6815192034_3fb85bf8a8.jpg" style="border: medium none;" width="500" /></a></div>
<br />
<br />
Je
me suis alors imaginé une France composée d'archipels de prospérité où
les communes les plus riches vivraient sur les hauteurs d'un relief
montagneux, les communes les moins prospères aux abords de lagons. Il
s'agirait d'un pays où il serait nécessaire de prendre le bateau puis
d'enfiler ses chaussures de randonnée afin d'atteindre Paris.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.flickr.com/photos/10519370@N04/6815245948/" style="margin-left: auto; margin-right: auto;" target="_blank" title="paris de mathieu rajerison, sur Flickr"><img alt="paris" height="296" src="http://farm8.staticflickr.com/7191/6815245948_369b45a522.jpg" style="border: medium none;" width="500" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Archipel parisien</td></tr>
</tbody></table>
<br />
<div style="text-align: left;">
Rien
n'empêche de regarder cette carte de plus près: au niveau de la région
parisienne, la carte fait apparaître deux lacs: un au niveau de
Sarcelles Saine-Saint-Denis, un autre vers Créteil. On voit également de
hauts sommets vers Neuilly-Sur-Seine et Saint-Germain-en-Laye ainsi que
Versailles.</div>
<br />
L'onirisme de la carte contraste avec la dureté du thème exposé.harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-77017498069434545562012-02-09T07:08:00.000-08:002013-02-06T06:12:28.426-08:00[3maps # 1] European Travel Patterns, the true size of Africa, if 7 Billion...In the 3maps series, I'll try to share with you, each month, a selection of 3 interesting maps that I'll have found on the web. <br />
<br />
<br />
<div>
<div style="color: #e69138;">
<b><span style="font-size: large;">Connecting</span></b></div>
<div style="color: #e69138;">
<b><span style="font-size: large;"><br /></span></b></div>
<b><i>European Travel Patterns by Eric Fischer</i></b></div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.flickr.com/photos/walkingsf/6794335193/" style="margin-left: auto; margin-right: auto;" title="European travel patterns de Eric Fischer, sur Flickr"><img alt="European travel patterns" height="500" src="http://farm8.staticflickr.com/7020/6794335193_f3a041aa70.jpg" style="border-style: none; border-width: medium;" width="500" /></a></td></tr>
<tr><td class="tr-caption"><br />
European travel patterns by Eric Fischer<br />
<br /></td></tr>
</tbody></table>
<br />
We find more and more maps representing connections from social
websites like Twitter or Facebook. These maps are interesting to
watch because of their dynamics. Also, they successfully unveil some connectedness aspects in the <i>real </i>world.<br />
<a name='more'></a>One of the artists I appreciate in this domain is <a href="http://www.flickr.com/photos/walkingsf/" target="_blank">Eric Fischer</a>. His work is mainly based on Twitter and cabspotting data.<br />
<br />
This map was created this way:<br />
<br />
<div style="color: #999999;">
<i>"60,000 trips (of 20 or more miles each) through 750,000
randomly-chosen geotags, grouped with 10-mile radius, from the Twitter
streaming API, August, 2011."</i></div>
<br />
Eric Fischer is a Twitter Mapper virtuoso. In this map, he manages to transform massive virtual data into a river-like landscape.<br />
<br />
<br />
<div>
<div style="color: #e69138;">
<b><span style="font-size: large;">Comparing</span></b></div>
<div style="color: #e69138;">
<b><span style="font-size: large;"><br /></span></b></div>
<b><i>The true size of Africa</i></b></div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.informationisbeautiful.net/2010/the-true-size-of-africa/" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="http://infobeautiful2.s3.amazonaws.com/true_size_of_africa.png" width="286" /></a></td></tr>
<tr><td class="tr-caption"><br />
The true size of Africa by Kai Krause <br />
<br /></td></tr>
</tbody></table>
<br />
With the map above, you can really figure out <a href="http://www.informationisbeautiful.net/2010/the-true-size-of-africa/" target="_blank">how big Africa is</a>.<br />
<br />
<br />
<b><i>If 7 Billion People Lived In One City, How Big Would It Be?</i></b><br />
<b><i><br /></i></b>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.fastcodesign.com/1665327/infographic-if-7-billion-people-lived-in-one-city-how-big-would-it-be" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="640" src="http://www.fastcodesign.com/multisite_files/codesign/imagecache/inline-large/post-inline/the-worlds-population-concentrated-2-A.jpg" width="536" /></a></td></tr>
<tr><td class="tr-caption"><br />
If 7 billion by Tim De Chant <br />
<br />
<br />
<div style="text-align: left;">
As one's always attempted to compare things relative to one's own
references, <i>relativeness </i>is an efficient way to represent data. In a different manner from the map of Africa, this
concept is used in <a href="http://www.fastcodesign.com/1665327/infographic-if-7-billion-people-lived-in-one-city-how-big-would-it-be" target="_blank">the map above</a> where it takes the population
density in different main cities in the world and apply the 7 billion
world's population to USA to see how it would fit. It gives an idea on the different densities of cities in the world and on how space can be saturated to the maximum.</div>
</td></tr>
</tbody></table>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0tag:blogger.com,1999:blog-9055497882207462476.post-57385200351414248842012-01-22T04:17:00.000-08:002013-02-06T06:11:40.873-08:00Classement du niveau de vie des départements: autre proposition de représentation<i>Here is a new attempt of associating the rank of a department's life level with its spatial location. It illustrates the flexibility of R in merging maps with numbers</i>.<br />
<br />
Auparavant, afin de pouvoir associer le rang d'un département à sa localisation, je vous avais proposé <a href="http://datagistips.blogspot.com/2012/01/une-petite-carte-socio-niveau-de-vie.html" target="_blank">une représentation figurant le classement sous forme de trajet</a>.<br />
<br />
Je vous en offre une autre qui est plus lisible selon moi. Sur celle-ci, le classement figure de part et d'autre et chaque département est colorié selon son classement, du bleu au jaune.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://picasaweb.google.com/lh/photo/NDiE53KxH8ivzMuUnfu9eMMgbHW51AOnNtzKTxSCN0c?feat=directlink" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-MxbGgwrBc-ZNeSnBx_9BujPQBqH-nb416jI8zcpBq5aCcp58N0WJW3bVluiV6LF9FYTAg015AvmT7lWDP-FqZnAYGWZsS7oaRfgJBnk6sCpt4yjYujIgkWWqlJcRpHqTwoxGHzJ6NpU/s640/geofla_order_final_gris.tiff" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span id="goog_692409426"><br /></span><span id="goog_692409427"></span></div>
<br />
<a name='more'></a> Avant, j'avais listé le classement du même côté et associé les couleurs aux lignes mais j'ai trouvé qu'avec la liste d'un même côté, les lignes formaient un amas assez confus. Aussi, la couleur associée aux lignes était inutile car la choroplèthe suffisait.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDTJ3UXZ2TlLmQCVmYFRcEdX4kVMh7Y-9-ZJYecn5X4_-CI5_2nhzmwN7yMmph5LKuMsHD-618NXTvbsW06rnYcDDW7401cMJOY-PrRjcZngncRQSKc4RECnwe9pA9sI7i7cDjMdv8_A4/s1600/geofla_order_final_memecote.tiff" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDTJ3UXZ2TlLmQCVmYFRcEdX4kVMh7Y-9-ZJYecn5X4_-CI5_2nhzmwN7yMmph5LKuMsHD-618NXTvbsW06rnYcDDW7401cMJOY-PrRjcZngncRQSKc4RECnwe9pA9sI7i7cDjMdv8_A4/s640/geofla_order_final_memecote.tiff" width="640" /></a></div>
harmonica-zoohttp://www.blogger.com/profile/08429694562689285954noreply@blogger.com0