Skip to content

Commit 9bee4db

Browse files
committed
Add viz nbs
1 parent 53c5386 commit 9bee4db

File tree

115 files changed

+212681
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+212681
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
resources/NaturalEarth
2+
*.ipynb_checkpoints*
3+
notebooks/outputs/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Creating Beautiful Geospatial Data Visualisations with Python
2+
3+
![alt text](https://github.com/symmy596/PythonMaps-Scipy-2022/blob/master/resources/assets/shapping_lanes_dark.png)
4+
5+
Presented by Dr. Adam Symington (PythonMaps)
6+
7+
This repository contains all the material needed by students registered for the "Creating Beautiful Geospatial Data Visualisations with Python" tutorial at SciPy 2022 on 12th July 2022.
8+
9+
For a smooth experience, you will need to make sure that you install or update your Python distribution and download the tutorial material before the day of the tutorial. Furthermore, there are a number of data sources (listed below) required for the tutorial. These will need to be downloaded and placed in the resources folder ahead of time.
10+
11+
This workshop will consist of four hands on tutorials / examples.
12+
13+
#### Visualising Points and Lines
14+
15+
The first part of this task will involve reading, manipulating, and plotting point data and the second will involve the creation linestrings from points. There will be a brief introduction on the task at hand and a run through of the tutorial as well as a brief discussion around the finer points of data visualisation.
16+
- Attendees will use the world port index to generate a map showing the locations of the world’s ports.
17+
- In the second half, attendees will use the locations of the world’s airports and data on the number of flights between each airport to generate a series of linestrings representing flightpaths and plot this data to show the worlds flight paths.
18+
19+
##### Learning Outcomes
20+
- Understand how to read and manipulate point/line data as well as generate points and lines from latitude and longitude values.
21+
- Understand how to plot point data with Matplotlib.
22+
- Understand how to generate linestrings from points using Shapely.
23+
- Understand how to plot line data with GeoPandas.
24+
- Understand how to reproject shape data using GeoPandas and Cartopy.
25+
26+
#### Visualising Polygons
27+
28+
Following a brief introduction, attendees will be tasked with creating visualisations using polygons and multipolygons. Attendees will use the Natural Earth dataset to generate different visualisations depending on which polygons take their fancy. An example will be provided showing how to overlay the worlds time zones onto a standard world map.
29+
30+
##### Learning outcomes:
31+
- Understand how to read and manipulate polygon and multipolygon data as well as generate polygons and multipolygons from latitude and longitude values.
32+
- Understand how plot polygons and multipolygons using GeoPandas.
33+
- Understand how to reproject polygons and multipolygons using GeoPandas and Cartopy.
34+
35+
#### Visualising Rasters
36+
37+
There will be a short introduction and then attendees will be tasked with creating visualisations using raster files. There are several open-source raster datasets available through NEO (NASA earth observations) and attendees will be encouraged to use whichever dataset takes their fancy. An example will be provided and discussed outlining how to plot the world’s population density.
38+
39+
##### Learning outcomes:
40+
- Understand how to read and manipulate raster data with Rasterio and rioxarray.
41+
- Understand how to plot raster data with Rasterio and Matplotlib
42+
- Understand how to reproject raster data with rioxarray.
43+
44+
#### Combing shapes with rasters
45+
46+
This section will outline how to overlay shape data like lines or polygons onto raster data like satellite imagery and how to use polygons to isolate specific parts of a raster. For example, use a polygon representing the borders of a country to isolate the data for that country in the raster image.
47+
48+
##### Learning Outcomes:
49+
- Understanding how to use geospatial reference systems to ensure that the shape data is overlaid on the raster data in the correct location.
50+
- Understanding how to use rioxarray to clip a raster according to the outline of a polygon.
51+
52+
53+
## Download Tutorial Materials
54+
55+
This GitHub repository is all that is needed in terms of tutorial content. The simplest solution is to download the material using this link:
56+
57+
https://github.com/symmy596/PythonMaps-Scipy-2022/archive/refs/heads/master.zip
58+
59+
If you are familiar with Git, you can also clone this repository with:
60+
61+
```
62+
$ git clone https://github.com/symmy596/PythonMaps-Scipy-2022.git
63+
```
64+
65+
It will create a new folder named `PythonMaps-Scipy-2022` with all the content you will need.
66+
67+
There are a number of datasets required for these tutorials. These will need to all be downloaded prior to the tutorial and placed in the resources folder.
68+
69+
70+
#### Tutorial 1 Points and Lines
71+
72+
- [World Port Index (WPI)](https://msi.nga.mil/Publications/WPI)
73+
- [Open Flights](https://openflights.org/data.html)
74+
75+
#### Tutorial 2 Polygons
76+
77+
- [Natural Earth](https://www.naturalearthdata.com/)
78+
79+
#### Tutorial 3 Rasters
80+
81+
- [Forests](https://globalmaps.github.io/ptc.html)
82+
- [Surface Temperature](https://neo.gsfc.nasa.gov/view.php?datasetId=MOD_LSTD_M&year=2021)
83+
- [NASA](https://neo.gsfc.nasa.gov/)
84+
85+
#### Tutorial 4 Rasters and Shapes
86+
87+
- [Topography](https://www.ngdc.noaa.gov/mgg/global/relief/ETOPO1/data/bedrock/grid_registered/georeferenced_tiff/)
88+
- [River Basins](https://www.fao.org/fishery/static/geonetwork/d47ba28e-31be-470d-81cf-ad3d5594fafd/data/)
89+
90+
91+
### Install Packages
92+
93+
To be able to run the examples, demos and exercises, you must have the following packages installed:
94+
95+
The following libraries are required to run the workshop
96+
97+
- geopandas==0.10.2
98+
- pandas==1.4.2
99+
- numpy==1.21.5
100+
- shapely==1.8.0
101+
- matplotlib==3.5.1
102+
- cartopy==0.20.2
103+
- rasterio==1.2.10
104+
- rioxarray==0.11.1
105+
106+
If you are using Anaconda, you can use the Anaconda Prompt (Windows) or Terminal.app (macOS) to create an environment with the necessary packages:
107+
108+
1. Open the Anaconda Prompt or Terminal.app using the below instructions:
109+
- **Windows**: Click Start and search for "Anaconda Prompt". Click on the application to launch a new Anaconda Prompt window.
110+
- **macOS**: Open Spotlight Search (using Cmd+Space) and type "Terminal.app". Click on the application to launch a new Terminal.app window.
111+
112+
2. Create a new Anaconda virtual environment by executing the below command in the application window you opened in step 1 above.
113+
114+
```
115+
conda create -n pythonmaps-tutorial jupyter geopandas==0.10.2 pandas==1.4.2 numpy==1.21.5 shapely==1.8.0 matplotlib==3.5.1 cartopy==0.20.2 rasterio==1.2.10 rioxarray==0.11.1
116+
```
117+
118+
3. To test your installation, please execute the `check_env.py` script in the environment where you have installed the requirements. If you created an Anaconda environment using the instructions above, keep the application window that you opened in step 1 active (or launch the platform specific application again -- Anaconda Prompt for Windows or Terminal.app for macOS), navigate to where you have this GitHub repository, and type:
119+
120+
```
121+
$ conda activate pythonmaps-tutorial
122+
$ python check_env.py
123+
```
124+
125+
You should see a window pop up with a plot that looks vaguely like a smiley face.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import rasterio
2+
import matplotlib
3+
import shapely
4+
import pandas as pd
5+
import geopandas as gpd
6+
import numpy as np
7+
import cartopy.crs as ccrs
8+
import matplotlib.pyplot as plt
9+
import rioxarray as rxr
10+
11+
fig, ax = plt.subplots()
12+
ax.scatter(x=[-3, -2, -1, 0, 1, 2, 3], y=[0, -1, -1.5, -1.75, -1.5, -1, 0])
13+
ax.scatter(x=[-1.5, 1.5], y=[2, 2], s=1000)
14+
ax.set_ylim((-3, 3))
15+
plt.show()

0 commit comments

Comments
 (0)