28févr./18

# Communes proches avec R

Dans mes travaux actuels, j’ai besoin d’identifier pour une commune en particulier, quelles sont les autres communes proches, pour un rayon donné de 20km. Pour obtenir une telle information, je me suis appuyé sur les données de communes d’Open Street Map. L’idée est simple :

• récupérer les frontières des communes ;
• les étendre ;
• regarder quelles communes sont en intersection avec les frontières étendues.
18janv./16

# Maps with R: slides

The other day, someone asked me if it was easy to do maps with R. My first thought was: « of course, it is ». I offered to prepare a few slides. I guess it was not that simple after all because one actually needs quite a lot of basic knowledge to be able to create its own map.

30oct./14

# Coordinates of « hot-spots »

Last week I uploaded a note about the paper @freakonometrics and I have submitted again after we added quite a few revisions. We have already made available most of the R code to reproduce our applications (on this GitHub repository). However, we did not share our method to obtain the coordinates of the « hot-spots » areas

22oct./14

# Kernel Density Estimation with Ripley’s Circumferential Correction

This is it! The revised version of a paper written with Arthur Charpentier has been submitted yesterday! It is untitled « Kernel Density Estimation with Ripley’s Circumferential Correction ». The paper is available on https://hal.archives-ouvertes.fr/hal-00725090.

19avril/14

# Maps with R

Last month, @freakonometrics posted a bunch of articles on his blog about the North pole (in French):

There are some maps on these articles that were produced using ggplot2 excellent package in R. We want to share our code here.

14févr./14

# Closest distance between countries

We sometimes need the distance between two countries in econometric models, for instance in gravity models. Bur for some countries, I think this measure could cause problem. Let’s take an example. If we want to model the volume of trade between country (i) and country (j), the economic theory says it will depend on the distance between (i) and (j). Let (i) be China, (j_1) Japan, and (j_2) India. The distance between (i) and (j_1) will be lower than between (i) and (j_2). Can we consider, though, that Japan is farther from China than India is?

So, rather than compute the distance between two head cities, it might be more accurate to compute the closest distance between the borders. If a border is shared by country (i) and country (j), then the distance should be zero.

25nov./13

# European Map using R

In this post, I will present a way to plot a European Union map using R. As you know, some countries are missing in the maps package. So, instead of working with that package, we will use the rworldmap one, available on CRAN. We will also need two more packages : ggplot2 and grid.

10nov./13

# Scale bar and North arrow on a ggplot2 map using R

After some research on the Internet, I gave up trying to find an R function to add a scale bar and a North arrow on a map, using ggplot().
So, I would like to present you what I have come up with.

The idea is really basic : we create two polygons for the scale bar, we add some text above, and we draw an arrow. That’s it. The only tricky thing here, is the way to obtain the coordinates of each element. An easy solution is to use the gcDestination function, from the maptools package.

27août/13

# Visualizing densities of spatial processes

In the past few weeks, Arthur Chaprentier (@freakonometrics) and I have been working again on an article untitled « Visualizing spatial processes using Ripley’s correction: an application to bodily-injury car accident location« .  The revised version of our work is available here: http://hal.archives-ouvertes.fr/hal-00725090.

Please note that this post is related to Arthur’s: http://freakonometrics.hypotheses.org/7129

27août/13

# Carte R interactive

Depuis un moment, j’avais envie de créer une version un peu animée des cartes R. Il y a bien la possibilité d’exporter les cartes au format gif, mais il manque le côté où on devient acteur…

En cherchant sur la toile, on tombe rapidement sur le tutoriel de Sylvain Prévost qui est plutôt bien expliqué. En parcourant les commentaires, un certain Romain propose son lien avec une petite amélioration : l’affichage de résultats.

Ce qui me plaît dans la méthode employée pour faire cette carte, c’est que ça se base sur un fichier SVG. Or, bien évidemment, R propose d’exporter les graphiques au format SVG… Aussi, je vous propose aujourd’hui, à partir de R et d’un peu de bidouille, de créer une visualisation interactive (un peu) de la carte de France. Mes compétences en JavaScript étant nulles, le résultat n’est pas exceptionnel, mais il est facilement reproductible. Merci à @YoruNoHikage pour ses conseils avisés en javascript et en css.