Creating Maps in Jupyter Notebook using GeoPandas

From CUOSGwiki
Revision as of 05:27, 21 December 2020 by Erci (talk | contribs)
Jump to navigationJump to search

Introduction

Aim

This tutorial will demonstrate how Jupyter Notebook can be used to manage and display spatial data in conjunction with Anaconda, GeoPandas, and QGIS. Using Jupyter Notebook in this procedure will enable you to develop your skills in scripting and automatic mapping while also learning more about open-source GIS software that is available. More specifically, this will involve using dynamic coordinate data to keep up-to-date maps and organize them in scripted notebooks. This workflow is accessible to users with less computational power, and data will be easier to store and manage. In the second part of this tutorial, we will show you how to display the data as a complete map (utilizing basic cartographic elements) in QGIS. This tutorial is designed for GIS users with some experience using graphic user interfaces, who are looking to get into using Python to streamline their workflow. The instructions and figures included in this tutorial were developed on the Windows operating system. If you are using a different operating system, your process may be slightly different.

About Jupyter

Jupyter Notebook was created by Project Jupyter, which is a collective which aims to develop open-source software in various programming languages. Jupyter Notebook specifically enables users to easily create and share code, as well as visualise data, among other uses. It is free to download and use (Jupyter, n.d.). While it runs in web browsers, it also runs locally on the user’s machine, which makes it easy to save version controls locally. Another advantage of Jupyter is that you can type code into kernels, and run those kernels individually. This will be demonstrated in the tutorial, but as a quick explanation -- the benefits to this include being able to test code easily and quickly visualize a certain data table, or in our case, create a map quickly without having to run all of the code at once. The main strength of Jupyter that we will be highlighting in this tutorial is its utility in visualising data that is updated frequently. The most pertinent example we have of that today are the daily updates in cases of COVID-19, which have been very effectively communicated through the use of maps.

About GeoPandas and CartoPy

GeoPandas is an open source library in Jupyter that builds off of pandas in Python. It is designed for users to more easily perform geospatial operations, by taking advantage of data frames in pandas, and creating spatial data frames. GeoPandas uses fiona for accessing files, Shapely objects for geometric manipulation and Matplotlib for plotting (geoPandas, n.d.). CartoPy is an open source package in Python that is designed for geospatial data processing. It takes advantage of shapely and NumPy libraries, and also uses matplotlib for plotting. It easily transforms points, lines and polygons based on geospatial projections, which helps virtualize and visualize data.

About QGIS

QGIS is a free and open-source comprehensive desktop GIS software with a wide variety of features that facilitate the display, analysis, and publishing of spatial data (QGIS, n.d.). In the context of this tutorial, QGIS enables us to expand on the work done in Jupyter by harnessing QGIS’ cartographic tools to produce a finished map with basic cartographic elements that can be saved and reused on updated iterations of the data.

Note on Software Versions

This tutorial uses the latest versions of software available at the time of writing (December 2020). The QGIS version used here is 3.16 Hannover, Python 3.9, and geoPandas 0.8.0. If you find updated versions of software when you try this tutorial, please note that there may be some differences in what you see in our screenshots and instructions, and what you see on your software.

Part 1: Getting Started

Part 2: Jupyter Notebook

Part 3: QGIS

Conclusion

References