Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotting geoJSON and shapefiles #1945

Closed
23ccozad opened this issue Jun 29, 2021 · 6 comments · Fixed by #1973
Closed

Plotting geoJSON and shapefiles #1945

23ccozad opened this issue Jun 29, 2021 · 6 comments · Fixed by #1973
Labels
Area: Plots Pertains to producing plots Type: Feature New functionality
Milestone

Comments

@23ccozad
Copy link
Contributor

As we move towards plotting WPC fronts (#1153), I'm wondering if there would be interest in plotting other various forecast products made available as geoJSON and shapefiles, potentially as part of the declarative interface. For example, the Storm Prediction center provides its convective outlooks in geoJSON format. The National Hurricane Center also provides a number of products as shapefiles.

https://www.spc.noaa.gov/gis/
https://www.nhc.noaa.gov/gis/

Behind the scenes, we could have geopandas read these files into GeoDataFrames, which Cartopy can then plot. I'm also thinking that users could pass in columns from which Cartopy can grab fill colors and/or stroke colors for each of the polygons/lines/points being plotted.

I toyed around with some of this mapping today and got some cool results. I could see it being very practical to combine these products with contour or barb plots of other variables as a way to supplement a weather analysis. Interested to hear what thoughts there are on this.

spc_outlook
nhc_probs

@23ccozad 23ccozad added Type: Feature New functionality Area: Plots Pertains to producing plots labels Jun 29, 2021
@kgoebber
Copy link
Collaborator

kgoebber commented Jul 6, 2021

This would be great functionality to MetPy and the declarative plotting interface. We do currently use shapefiles for USCOUNTIES and USSTATES, which are static files contained in the library. I've not yet had a chance to play with Geopandas, but a quick review looks neat!

Thinking a little bit about implementation, the way most of our declarative interface works, the reading happens independent of plotting, so we would not necessarily add a hard dependency on Geopandas (which looking at their dependencies only adds Fiona beyond what we already use), but that could be an initial format we accept for plotting. Would it be useful to think about how we could support other object types for being able to plot shapefiles and GeoJSON data?

Anyway, would love to see this as I only see the availability of forecast and other data increasing in these formats and wanting a nice way to plot them up with other meteorological data.

@dopplershift
Copy link
Member

It would be interesting to add support to declarative (if we can do it without making the implementation too ugly). The way I've usually added something like this to MetPy in the past is to first put together a full demo and then look to see what the hard/lengthy parts are and look at standardizing those in MetPy. So @23ccozad if you'd like to put together a demo notebook (that could end up on the training site), we can use that as a starting point to identify what MetPy could actually help with.

@23ccozad
Copy link
Contributor Author

23ccozad commented Jul 7, 2021

Thanks for the feedback! I'll work on a demo notebook over the next few days and see what I can come up with.

@23ccozad
Copy link
Contributor Author

@dopplershift @kgoebber

Here is a demo notebook I've put together for a new class in declarative that plots GeoJSON/shapefile:
https://gist.github.com/23ccozad/8c5ee73731c466be2ed00817aabd792d

This is definitely still a draft, so I'll be interested in seeing what areas you all think could be improved.

@kgoebber
Copy link
Collaborator

My first reaction is - Wow! This looks great as a first pass and much better than anything I could have done. In addition to plotting some of these meteorologically specific polygons/lines, I see this as a potential to an expanded capability to add "layers" to any map in addition to what is incorporated into the MapPanel() layers attribute, that would be hard to incorporate there directly and could be an avenue to plot other common static layers that we don't yet (or might not) incorporate directly into the declarative syntax.

The only think I noticed on quick glance is related to the fontcolor and fontoutline variables where I think the inputs to those got reversed. It would make sense that the fontoutline is associated with the edgecolor and fontcolor is associated with the facecolor. Although the way you have it does produce a neat effect, it seems more logical to have it the other way. But I am open to other suggestions, especially if we can build in a bit more control over labels (see below).

The only thing I am thinking that could be added is to have a bit more control over the label color separately from the geometry color. Using the geometry color by default, but then having the option to set label_facecolor and label_edgecolor separately in case there is a slightly different look that is desired.

The examples that you plotted are excellent and some of the most common that would be used within the field. I assume this should also work with other shapefiles (e.g., roads, locations, etc.). It would be good to make sure that at least some of those common elements would also plot well in this scheme. I don't know if any of these are available remotely like the NHC and SPC examples, but "should" be able to be loaded locally with the files saved in zip format.

@23ccozad
Copy link
Contributor Author

Thanks for the detailed comments, @kgoebber! I went ahead and updated the gist to add label_facecolor and label_edgecolor traits. Also threw in another example to demonstrate how we can use this to plot roads and cities as well.

Next steps at this point will be adding docs and tests for the class, open a PR, and then go from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Plots Pertains to producing plots Type: Feature New functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants