Difference between revisions of "Geopandas and Matplotlib to automate data processing and mapping"

From CUOSGwiki
Jump to navigationJump to search
Line 7: Line 7:
   
 
Additionally, we will be using this data as a [https://open.ottawa.ca/datasets/wards-2010 reference layer] for our maps. It is the boundaries of the different regions within Ottawa.
 
Additionally, we will be using this data as a [https://open.ottawa.ca/datasets/wards-2010 reference layer] for our maps. It is the boundaries of the different regions within Ottawa.
  +
________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________
 
   
===Setting up Your Environment===
+
====Setting up Your Environment====
  +
  +
'''The first step of this tutorial is going to be how to set up your Python environment in order to complete this tutorial.'''
  +
  +
- You will need to download Anaconda: https://docs.anaconda.com/anaconda/install/windows/
  +
  +
- Search for and open the Anaconda Prompt
  +
  +
- Create your environment and when prompted, type y to accept:
  +
$ conda create --name geo_env
  +
  +
- Activate your Anaconda virtual environment by typing:
  +
$ conda activate geo_env
  +
  +
- Install the first required packaged called geopandas:
  +
$ conda install geopandas
  +
  +
- Install the second package called matplotlib:
  +
$ conda install matplotlib
  +
  +
- Install the third package called contextily:
  +
$ conda install contextily
  +
  +
- Install the last and final package from Anaconda which allows you to map polygons using Geopandas:
  +
$ conda install -c conda-forge descartes
  +
  +
- Next you will need an integrated development environment (IDE). This tutorial used Visual Studio Code (VS Code) as it is free and accessible. However, other IDEs such as Pycharm can be used. The link to install Visual Studio Code can be found here: https://code.visualstudio.com/download
  +
  +
- You will now need to open VS Code and set your interpreter to the virtual geo_env environment you created. You can follow this tutorial: https://code.visualstudio.com/docs/python/environments#:~:text=To%20do%20so%2C%20open%20the,Settings%2C%20with%20the%20appropriate%20interpreter.
  +
  +
  +
We finally have our entire Python environment set up!
  +
  +
***

Revision as of 16:15, 1 December 2020

Road Construction Visualizer

This tutorial will be an introduction to using Geopandas and Matplotlib to automate data download, data cleaning, basic analysis and map making. A basic understanding of Python, Python interpreters and Python module download will be assumed in this tutorial.

The data for this tutorial is hosted on Open Ottawa and can be found here. It has an application programming interface (API) which will also us to make requests to download data. Ensure to view the data tab on the City of Ottawa website. Explore a few pages and get familiar with the data. Pay special attention to the TARGETED_START date as this is the row we will be primarily dividing our validated data by. Additionally, take a look at the STATUS column and see if you can find a row that contains a NOTAVAIL value. When working with data, it is always important to become familiar with the data. Keep an eye out for any data that has missing values.

Additionally, we will be using this data as a reference layer for our maps. It is the boundaries of the different regions within Ottawa. ________________________________________________________________________________________________________________________________________________________________________________________

Setting up Your Environment

The first step of this tutorial is going to be how to set up your Python environment in order to complete this tutorial.

- You will need to download Anaconda: https://docs.anaconda.com/anaconda/install/windows/

- Search for and open the Anaconda Prompt

- Create your environment and when prompted, type y to accept:

        $ conda create --name geo_env

- Activate your Anaconda virtual environment by typing:

        $ conda activate geo_env

- Install the first required packaged called geopandas:

        $ conda install geopandas

- Install the second package called matplotlib:

        $ conda install matplotlib

- Install the third package called contextily:

        $ conda install contextily

- Install the last and final package from Anaconda which allows you to map polygons using Geopandas:

        $ conda install -c conda-forge descartes

- Next you will need an integrated development environment (IDE). This tutorial used Visual Studio Code (VS Code) as it is free and accessible. However, other IDEs such as Pycharm can be used. The link to install Visual Studio Code can be found here: https://code.visualstudio.com/download

- You will now need to open VS Code and set your interpreter to the virtual geo_env environment you created. You can follow this tutorial: https://code.visualstudio.com/docs/python/environments#:~:text=To%20do%20so%2C%20open%20the,Settings%2C%20with%20the%20appropriate%20interpreter.


We finally have our entire Python environment set up!