Making nice maps for posters with Python 🗺️+🐍
Contents
Making nice maps for posters with Python 🗺️+🐍¶
To communicate your results effectively to people 🧑🤝🧑, you may come to a point where making maps are needed.
These maps could be created for a conference poster, a presentation, or even for a social media 🐦 post!
In this tutorial 🧑🏫, we’ll focus on making basic 2D maps, and by the end of this lesson, you should be able to:
Set up basic map elements - basemap, overview map, title and axis annotations 🌐
Plot raster data (images/grids) and choose a Scientific Colour Map 🌈
Plot vector data (points/lines/polygons) with different styles 🗠
Save and export your map into a suitable format for your audience 😎
🎉 Getting started¶
Once you have an idea for what to map, you will need a way to draw it 🖌️.
There are plenty of ways to make maps 🗾, from pen and paper to Photoshop.
We’ll start by loading some of these tools, that help us to process and visualize our data 📊.
import icepyx as ipx # for downloading and loading ICESat-2 data
import pygmt # for making geographical maps and figures
import rioxarray # for performing geospatial operations like reprojection
import xarray as xr # for working with n-dimensional data
Just to make sure we’re on the same page, let’s check that we’ve got the same versions.
print(f"icepyx version: {ipx.__version__}")
pygmt.show_versions()
icepyx version: 0.6.2
PyGMT information:
version: v0.6.0
System information:
python: 3.9.10 | packaged by conda-forge | (main, Feb 1 2022, 21:24:11) [GCC 9.4.0]
executable: /usr/share/miniconda3/envs/hackweek/bin/python
machine: Linux-5.13.0-1021-azure-x86_64-with-glibc2.31
Dependency information:
numpy: 1.22.3
pandas: 1.4.1
xarray: 0.21.1
netCDF4: 1.5.8
packaging: 21.3
ghostscript: 9.54.0
gmt: 6.3.0
GMT library information:
binary dir: /usr/share/miniconda3/envs/hackweek/bin
cores: 2
grid layout: rows
library path: /usr/share/miniconda3/envs/hackweek/lib/libgmt.so
padding: 2
plugin dir: /usr/share/miniconda3/envs/hackweek/lib/gmt/plugins
share dir: /usr/share/miniconda3/envs/hackweek/share/gmt
version: 6.3.0
A note about layers 🍰¶
What do you do when you want to plot several datasets overlapping the same geographical area? 🤔
A general rule of thumb is to have the raster images on the ‘bottom’ 👎🏽, and the vector data plotted on ‘top’ 👍🏽.
Think of it like making a fancy birthday cake 🎂, starting with the dense cake flour (raster), and decorating the colourful icing on top!
0️⃣ The data¶
Download ATL14 Gridded Land Ice Height 🏔️¶
This is a 125m ATLAS/ICESat-2 L3B raster grid product over the cryosphere (ice) regions.
Specifically, this includes places like:
Antarctica (AA) 🇦🇶
Alaska (AK) 🏴
Arctic Canada North (CN) 🇨🇦
Arctic Canada South (CS) 🇨🇦
Greenland and peripheral ice caps (GL) 🇬🇱
Iceland (IS) 🇮🇸
Svalbard (SV) 🇸🇯
Russian Arctic (RA) 🇷🇺
🔖 References:
Smith, B., B. P. Jelley, S. Dickinson, T. Sutterley, T. A. Neumann, and K. Harbeck. 2021. ATLAS/ICESat-2 L3B Gridded Antarctic and Arctic Land Ice Height, Version 1. Boulder, Colorado USA. NASA National Snow and Ice Data Center Distributed Active Archive Center. doi: https://doi.org/10.5067/ATLAS/ATL14.001.
Official NSIDC download source - https://nsidc.org/data/ATL14
Source code for generating ATL14/15 - https://github.com/SmithB/ATL1415
# Set up an instance of an icepyx Query object
# for a Region of Interest located over Iceland
region_iceland = ipx.Query(
product="ATL14", # ICESat-2 Gridded Annual Ice Product
spatial_extent=[-28.0, 62.0, -10.0, 68.0], # minlon, minlat, maxlon, maxlat
)
Inside of the region_iceland class instance are attributes
that can be accessed using dot ‘.’ something.
⏩ Type out region_iceland. and press Tab to see some of them!
# Check that we've selected the right region
region_iceland.visualize_spatial_extent()