Chapter 7 Visualizations with Leaflet I

7.1 Plot densitiy of rides

Let’s have a look at the distribution per hour of the day of the number of aggregated trips :

So many outliers…

The leaflet package is the way to go when you want to implement interactive maps in R, especially when working in a Shiny project.

we start by defining the data we want to plot: the density of trips, at 5 am for street with more than 10 occurences, not motorway, neither tunnel :

And here we go with Leaflet : (we filter on 5 am and use a CartoDB theme, more info here)

Now let’s add the coordinates of the nightclubs in Berlin. For this, we load an other shapefile, the one with the buildings informations, from the GeoFabrik folder :

Let’s filter the night life amenities :

We add the nightclub class data to the Leaflet plot :