Summary

This short analysis is done for a self-training purpose. The goal here is to try the ggmap package. In order to do so, we will map the “Musées de France” located in Paris. “Musées de France” is a specific label which regroups some French museums.

ggmap is a package from D. Kahle and H. Wickham. : Spatial Visualization with ggplot2. The R Journal, 5(1), 144-161

The dataset was found on the French goverment open data website.

Data source: https://www.data.gouv.fr/fr/datasets/liste-et-localisation-des-musees-de-france/

Data file: https://www.data.gouv.fr/s/resources/liste-et-localisation-des-musees-de-france/20160404-110647/Liste_musees_de_France.xls

Data cleaning

We are going to deal with French accent specifities. I noticed that csv wasn’t working correctly (it replaced accent by coma or @ symbols, etc…). So I saved the xls as a text unicode and then load it into R with UTF-8 encoding.

#I used txt to deal with accent and language specificities
data.source <- read.delim("C:/Users/marc/Desktop/Data/160907_Musee de France/Liste_musees_de_France.txt", stringsAsFactors=FALSE, encoding= "UCF-8")
data.source <- tbl_df(data.source)

data.cleaned <- filter(data.source, NOMDEP == "PARIS")

#I noticed the research sometimes didn't work when some special character are involved so I replaced them...sadly
data.cleaned$ADR <- gsub("é", "e", data.cleaned$ADR)
data.cleaned$ADR <- gsub("è", "e", data.cleaned$ADR)
data.cleaned$ADR <- gsub("ô", "o", data.cleaned$ADR)

#add the long and lat info for each museum
data.cleaned$full.adr <- paste(data.cleaned$ADR, "Paris")
latlong <- geocode(data.cleaned$full.adr)
data.cleaned <- cbind.data.frame(data.cleaned, latlong)

#watercolor map
Paris.map.watercolor <- get_map("Paris", zoom = 12, source = "stamen", maptype = "watercolor")


#toner map
Paris.map.toner <- get_map("Paris", zoom = 12, source = "stamen", maptype = "toner")
ggmap(Paris.map.watercolor, extent = "device") +
      geom_point(data= data.cleaned, 
                 aes(x = lon, y = lat), size=5, colour="#8F1383")+
      ggtitle("Musées de France located in Paris")

ggmap(Paris.map.toner, extent = "device") +
      geom_point(data= data.cleaned, 
                 aes(x = lon, y = lat), size=5, colour="#B72A67")+
      ggtitle("Musées de France located in Paris")