Enhancements to Plotting Capabilities in MetPy

Editor's Note:
Due to the COVID-19 pandemic, Unidata's 2021 summer interns did not travel to Boulder to work on their projects in person. Instead, they interacted with Unidata developers through Slack, Zoom, and other electronic means.

Connor Cozad
Connor Cozad

I spent this summer with Unidata contributing new features and improvements for version 1.1.0 of MetPy. This release is the first to introduce new features since 1.0 debuted in December 2020. I focused on enhancements to MetPy’s declarative interface, which allows users to plot datasets on maps. These new capabilities provide greater control over map design and introduce support for plotting additional data formats.

GEMPAK-style Region Modifiers

Map zooming
Map zooming
(click to enlarge)

In previous versions of MetPy, users could set the extent of a map by providing a state’s two-letter postal abbreviation. For example, a map whose area was set to ‘co’ would display a map centered on the state of Colorado. This often provided more convenience than figuring out and setting the bounding latitudes and longitudes for the map extent. This feature was originally part of GEMPAK, a legacy software package used for reading, visualizing, and performing calculations with weather data.

GEMPAK also allowed users to append a ‘+’ or ‘-’ suffix to these area strings as an easy way to zoom in and out. For example, a map whose area was set to ‘co+’ would result in a map centered on Colorado but zoomed in. I spent part of my time this summer adding in the ability to use these suffixes in MetPy. Ryan May, Kevin Goebbert, and I dug up some of the Fortran code from GEMPAK to make sure the MetPy implementation was in line with that of GEMPAK. I’m happy to say that users can start taking advantage of these suffixes to zoom in and out of maps starting with version 1.1.0.

Plotting geoJSON and Shapefile Data

Plotting shapefile data
Plotting shapefile data

A number of geographical and meteorological datasets are meant to be plotted in Google Earth or a GIS software application. NOAA’s Storm Prediction Center and National Hurricane Center make many of their forecast products available in geoJSON or shapefile formats. Cities, roads, states, counties, and other map layers are often available in these formats as well.

I spearheaded the development of MetPy’s new PlotGeometry class, making it easy to plot data from geoJSON files and shapefiles. Users can read these formats in Python with the Geopandas library, which produces a GeoDataFrame with a column titled "geometry." This column contains all the points, lines, and polygons from the file that can be plotted on the map. The new PlotGeometry class takes this geometry, as well as several optional attributes like fill color, stroke color, and labels, and handles the plotting process. This is another feature I’m very excited to have included in MetPy 1.1.0.

These are just two highlights out of many different enhancements, maintenance tasks, and bugs I helped with this summer. I’ve put together a Jupyter notebook demonstrating four of the new features that I created, two of which I’ve discussed above. In addition, I put together a second notebook focused solely on using the PlotGeometry class. It has been great to see the effort being put forth by Unidata to support the geoscience community, and I am glad to have been a part of that effort this summer.


Post a Comment:
Comments are closed for this entry.
Unidata Developer's Blog
A weblog about software development by Unidata developers*
Unidata Developer's Blog
A weblog about software development by Unidata developers*



News@Unidata blog

Take a poll!

What if we had an ongoing user poll in here?

Browse By Topic
Browse by Topic
« March 2023