Exploring tourism in France with interactive maps

[This article was first published on R – Enhance Data, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Since summer is coming and meaning vacations we are going to explore the tourism in France. To do so, we are going to explore the number of hotel room per deparements (a small administrative area in France) and see if somes show more tourist appeal than others.

1.The data:

To do this analysis, we are gong to use several dataset availables online:

1.b: Packages:

2.Data preprocessing:

We wish to assess the number of hotel room per capita in the different area, so w will:

  1. Count the number of rooms per ZIP-code using DF1:
##Loading the number of room per ZIP code
HotelFrance=data.table(read.csv("~/data/DF1.csv", sep=";", stringsAsFactors=FALSE))

2.Join the ZIP code with the area using DF2

##Join between Zip code/area code and number of rooms
CPInsee <- read.csv("~/data/DF2.csv", sep=";", stringsAsFactors=FALSE)

3. Loading the departement names (DF4) and correcting some typos:

##Loading the number of room per ZIP code
##Join between Zip code/area code and number of rooms
CPInsee=read.csv('~/Data/DF3.csv', sep=';', stringsAsFactors=FALSE)

4.Joining the population data and the Datatable from 3.

###Exploring the number of room per capita:

##Loadin the number of capita per departement
PopDep <- data.table(read.csv("~/Data/DF3.csv", sep=";",stringsAsFactors = F))
PopDep[,Population:=as.numeric(gsub(' ','',Population))]

###Joint between population/room

3. A first plot

Now that all our data are together, let’s plot a first map: The number of rooms per 1000 inhabitants:

###Correcting some mistakes

Map<-"fr-all-all.geo.json" %>%
jsonlite::fromJSON(simplifyVector = FALSE)
highchart(type = "map") %>%
hc_title(text = "Number of room per 1000 inhabitants") %>%
hc_mapNavigation( enableMouseWheelZoom=T)

We corrected some names to have Corsica correctly plotted. Running the code above, you should get the same plot plot, but it will be interactive.


4. A first model:

As we see above, most of the areas have the same colors, meaning we should be able to fit a linear model Number Of Room~Number Of Inhabitants.

###In an ideal case, the number of room should be proportionate to the number of inhabitants
##R²=0.28, not that bad and 0.36 without paris

Using this code, we are getting an R² of 0.28 for Model1 and 0.37 for the second model. Deleting Paris from the model seems appropriate for several reasons:

  • It’s a clear outlier with an internally deleted residuals of 21 (!) and a cook’s D of 4.1.
  • The outlyingness can easily be explained by the fact that Paris is … well Paris and attract much more tourist than most of France. Paris should be studied on its own.
Rplot09 Rplot08

The study will now focus on the second model.

5. A geographic exploration of the residuals of Model 2

Our goal here isn’t that much the model but seeing how the differents area behave according to the model. Instead of plotting the residuals distribution, let’s see how the maps of France look when each departement is assigned its resiudal value. A strongly negative residual would show a low appeal (i.e a lot of inhabitants but only a few tourists facilities) whereas a highly positive residual would show a high appeal.

##If the data was to be fitted by a lm, all the area should have more or less the sam color.
##Some outliers, Paris, Corsica, HAute Pyréne and Alps
n <- 6
dstops <- data.frame(q = 0:n/n, c = substring(brewer.pal(n+1, 'RdBu'), 0, 7))
dstops <- list.parse2(dstops)

MapResiduals2<-"fr-all-all.geo.json" %>%
jsonlite::fromJSON(simplifyVector = FALSE)
highchart(type = "map") %>%
hc_title(text = "Residuals per area") %>%
hc_mapNavigation( enableMouseWheelZoom=T)%>%
hc_colorAxis(min = -10000, max =10000,stops = dstops)


After some investigations, the map seems logical:

  • The deep blue area with a strong tourist attraction are respectively (from west to east): Pyrenees, French riviera, the Alps and Corsica.
    Pyrenees and the Alps have both a lot of ski resort and aren’t densely populated.
    French rivieria is more populated which lower the impacts of its tourism.
  • The north of France is densely populated and hasn’t a lot of tourist appeal.




To leave a comment for the author, please follow the link and comment on their blog: R – Enhance Data.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)