Exploring the maps’ administrative divisions using QGIS

This article is the second in a series focused on building our own datasets to plot maps in R. Soon, you will find here the links to all the articles.

In this article we will…

  • Check some examples of administrative divisions.
  • Review the main differences between Natural Earth and GADM.
  • Load a map in QGIS and explore its attributes.

In the previous article, we explored how to use ggplot2 to create visualizations using maps. However, not all the countries are included in this package, so we will have to obtain our own coordinates datasets to show any region we want.

Administrative divisions

One of the main challenges when generating political maps of each country is that each has different administrative divisions. In general, five administrative levels are recognized (numbered from zero to four), but some countries only use one or two of them.

Level zero represents each country and level one represents the main division of each (here we usually talk about states, departments, regions, and others). On the other hand, level two is not standardized at all (some examples include counties, municipalities, cities, and others), and in the same country, the third and fourth levels may present several differences from one region to another.

Let’s check some examples.

Generating datasets for any administrative division

Once we know about the many different administrative divisions that exist, we realize why R doesn’t include map data for every single country.

In order to generate our datasets to plot our custom maps in R, first, we need some geographical information. This information is distributed in shapefiles, which are files that contain all the geometric information to represent countries, administrative divisions, and geographical features, on a coordinate system (i.e., latitude and longitude). Several pages provide shapefiles for different needs.

Natural Earth: politic and geographical maps

According to their own description on their site: Natural Earth is a dataset with public domain maps in different scales. It provides both raster image maps and vector maps that we can use in the cartographic software of our choice.

The main objectives of Natural Earth are:

  • Convenience: Clean, legible maps ready to be used by any cartographer.
  • Neatness counts: Maps in different scales, handmade to ensure consistency. The geographical features coincide in place when using different datasets.
  • GIS attributes: The maps contain a lot of information, for example, the name of the regions in several languages and the size of the geographical features.

Natural Earth provides a variety of shapefiles, both with cultural and physical information; however, the administrative divisions information on their maps, vary a lot from country to country. For example, some countries only have their level 1 divisions represented, when others have their level 2 and 3 mixed.

GADM: focus on administrative divisions

The objective of GADM is to create maps with all the administrative divisions of all countries. GADM’s maps have a higher resolution than Natural Earth’s ones, they are a good option when we need a lot of details in the frontiers that divide a region from another.

GADM allows us to download the information of each separate country or a worldwide map; for each of these options, it offers shapefiles of each administrative level, which gives us better control over the divisions that we want to show on the map.

QGIS

QGIS is a free and open-source Geographical Information System, that can be used to import the shapefiles provided by Natural Earth or GADM, and export the vertices in the format that ggplot2 requires to plot them.

To install QGIS follow this download link.

For ease of use, we should download and install the QGIS Standalone Installer; the OSGeo4W allows access to several projects including QGIS, but requires many additional configurations. For the QGIS installer, we only need to run it and use the default configurations. After installing QGIS we have access to the following graphical interface.

Loading our first layer

In order to work in QGIS, we first need to download a shapefile from Natural Earth or GADM.

To begin, I recommend working with Admin 1 — States, provinces from Natural Earth. The GADM’s shapefiles have a lot of frontier details, but because of this, they can be hard to process on some computers.

After downloading, we will have the ne_50m_admin_1_states_provinces.zip file in our system, which we need to unzip to get the following files.

Now go to QGIS and from the main menu select Layer > Add Layer > Add Vector Layer…

The Data Source Manager | Vector window will open. At the top, select the File option and then in Vector Dataset(s) navigate to find the .shp (shapefile) file that we previously downloaded and unzipped. Finally, click on Add and after waiting for a couple of seconds, the map will be loaded.

Let’s quickly check the attribute table. In the left panel, Layers, right-click on the layer that we just loaded and pick the option Open Attribute Table. You can also press F6 as a shortcut to access this table.

Take a moment to explore the table. Find the admin column and then find your country there. Check which regions are included in it; to do this, after finding your country, find the name column. It is recommended to also check the iso_a2 to select a country more easily.

In conclusion

Since each country has its own history and government, the administrative divisions vary a lot. This information and many are included as attributes in maps, much of this data is even available in multiple languages.

In the following article, we will use the tools that this table provides us to select some countries and generate a dataset to plot our map in R.