Tile / Grid maps have appeared in many news / blog articles and have gained popularity over choropleth maps. However, tile maps also suffer from a limitation that they distort the geographic locations. Since all the areas on a map are of equal sizes i.e rectangles or circles or hexagons the actual boundary / geography is distorted.
There are a quite a few articles where tile maps are used and they do a fantastic job in explaining the story behind the underlying data. Some of the examples are as follows:
1) FiveThirtyEight: The article uses tile map to show the tax revenue for each US state and their sources.
2) Economist: The article explores the topic regarding death row execution in USA. The tile map is overlayed with text color and icons to explore the data.
3) Washington Post: Uses tile maps to exhibit the data related to measles outbreak and states with exemptions of vaccines. Three tile maps are shown side by side and this lets the viewer compare the states that have exemption due to religious, philosophical and medical reasons.
As shown above tile maps do a great job even with the geographic distortion. But, all these maps are related to United States and not India. So how do we create tile maps for India in R. The main purpose of this post is to introduce readers to concepts such as shapefiles, geogrid package and tile map for India.
For the purpose of this post we will download the geogrid R package. The package along with example is available on the authors github. Some of the code used in this post is written by the author and we will simply edit it for our purpose
The first step to creating a tile map is to get a shapefile for India. Indian shapefiles are available here. However, these shapefile are not perfect as we will see the Jammu and Kashmir portion is not mapped accurately. since, we will create a tile map and every Indian state will be a rectangle this is not be an issue for us.
Shapefiles are available at various granularity i.e. national, state, district, taluka etc. We require state level shapefile. The shapefile we will use for this post is available here. I have added one additional column called ABB to this shapefile using Qgis. Since the names of Indian states are long we can label each state in our tile using the abbreviation.
Shapefiles are easy to work with if used along with Qgis. Working with Qgis is easy and online help for the same is easily available. R also allows us to work with shapefiles but for now we will not do that.
This is the tile map that we will generate. We will see in the following post how to create this tile map. The geogrid package allows us to set 6 different seed types and every seed will generate a tile map with slightly different shape.
For the purpose of this post let us ignore the underlying data and colors. As discussed above the shape of each Indian state is now a rectangle hence all the states have equal area.
The process of creating a tile map can simply be broken down into 5 easy steps:
- Get shapefile -> India shapefile
- Get the data -> literacy data
- Link your data to the shapefile -> one in R after few data manipulation steps
- use the geogrid package to create a rectangle or a hexgon tile map
- use the data to fill each rectangle in our tile map using a color to represent the data.
The current post explains the advantages and limitations of a tile map as well as introduces shapefiles which are building block for a tile map. In the following post we will go over each step described under the section titled process.