R Tutorial: Map Tiles

preview_player
Показать описание

---
The leaflet package comes with over 100 base maps you can use. In this video, we will start to explore the various tiles that we can use as the foundation of our web maps.

As you work through the exercises, I encourage you to experiment with different base maps to expand your awareness of the available options. When you are selecting a base map there are several important questions to consider. Perhaps, primary among them is "Why are you making this map in the first place?" Is this map just for your use or is it part of a larger project that should fit within an existing design framework? Secondly, "what type of data will you be plotting?" Will the geographic and topographic features of the base map add to the information you are presenting or confuse your users?

In my work, I tend to prefer grayscale maps when plotting data. I find that these maps make it easier for me to distinguish between the data that I am plotting and the data included with the base map. For example, in the map on the left the points are similar in color to features of base map, like the lakes, whereas in the map on the right the data we are plotting is easily distinguishable from the features of the base map.

There are over 100 provider tiles included in the leaflet package. Most of these tiles you can use by calling the addProviderTiles() function. However, there are a few, like mapbox, that you will need to register for prior to using them. You can access the names of the provider tiles included in the leaflet package by calling the names() function on the providers list. For example, to see the first five provider tiles, we call names() on the providers list followed by 1 colon 5 in brackets.

The first five tiles are all OpenStreetMap tiles, so it might be more useful to print all of the tiles provided by OpenStreetMap, which you can do by using the str_detect() function from the stringr package.

We can swap the default base map out for any of the included provider tiles using the addProviderTiles() function. For example, to create a leaflet map that uses the black and white OpenStreetMap, we replace the addTiles() with addProviderTiles() and pass in the name of the desired tile to the function.

Now it’s time to put this into practice using the CartoDB provider tiles.

#R #RTutorial #DataCamp #Interactive #Maps #leaflet
Рекомендации по теме