Plotting global map with data from net cdf...

41 views
Skip to first unread message

Sundar J

unread,
Nov 10, 2019, 1:35:21 PM11/10/19
to pyqtgraph
I am planning to develop a small GUI which will contain a global map and on top some data from netcdf files would be plotted. Is it possible with pygtgraph? I have not come across such a example in the documentation or in blog tutorials. Could some one lead me right direction...

Evangelos Petsalis

unread,
Nov 11, 2019, 11:48:23 AM11/11/19
to pyqt...@googlegroups.com
Is there a specific reason you want to use PyQtgraph? Do you want the map to be in a 3D form so you can flip and rotate?
If not, then Basemap would be a much easier tool to use, and then you can embed those figures in whatever GUI you feel like, such QT.



On Sun, Nov 10, 2019 at 10:35 AM Sundar J <wrf...@gmail.com> wrote:
I am planning to develop a small GUI which will contain a global map and on top some data from netcdf files would be plotted. Is it possible with pygtgraph? I have not come across such a example in the documentation or in blog tutorials. Could some one lead me right direction...

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/42938633-c5dd-4467-a433-c1c01e47bc05%40googlegroups.com.

Israel Brewster

unread,
Nov 11, 2019, 12:01:15 PM11/11/19
to pyqtgraph
It’s entirely possible, with a bit of work. I’ve done exactly that, opting for pyqtgraph over basemap for performance reasons - with pyqtgraph I can get a zoomable, pannable map that works well. Basemap is fine for static maps.

The key to plotting geographic data in pyqtgraph is to convert everything to a projection that you like, such as mercator. At that point, everything is in meters and can be plotted as simple x and y coordinates. Getting the map background can be a bit tricky though, depending on your needs. For example, if you want to be able to zoom from “whole earth” to “city” level, a single bitmap won’t work very well, so you’ll have to figure out an alternative. On the other hand, if you only need minimal zoom, then it’s just a matter of finding/creating an appropriate bitmap image for your map background, and using it as a background image on the plot.

Finally, if you want the axis to display latitude/longitude rather than meters in your projection, you’ll have to subclass axisitem and override tickStrings and tickValues to re-project the meter based values back to lat/lon. This works well for the mercator projection, where latitude and longitude lines are a straight grid, but I don’t know how well it would work (or if it would work at all) for any of the projections where latitude and longitude are curving lines. For those, you may just have to hide the axis completely and rely on your background image.

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320

Sundar J

unread,
Nov 12, 2019, 12:10:26 PM11/12/19
to pyqt...@googlegroups.com
Exactly the kind of functionally I am looking for. However, I also need to move the map area by mouse drag so that area along with data is updated on the GUI. 

The GUI I am looking for is similar to zygrib or xygrib (https://github.com/opengribs/XyGrib). This used cpp with qt for plotting map. I don't know if the same technique can be implemented under python.

I feel that pyqtgraph should have integration with earth science packages to reach to larger audience.

I came here for the reason that the package is faster and updating to the existing plot is feasible. However, it looks like it is very difficult. 

Israel Brewster

unread,
Nov 12, 2019, 12:22:20 PM11/12/19
to pyqtgraph
On Nov 12, 2019, at 8:10 AM, Sundar J <wrf...@gmail.com> wrote:

Exactly the kind of functionally I am looking for. However, I also need to move the map area by mouse drag so that area along with data is updated on the GUI. 

That capability (along with mouse wheel or drag-rectangle zoom in/out) comes built-in with pyqtgraph, no work needed.


The GUI I am looking for is similar to zygrib or xygrib (https://github.com/opengribs/XyGrib). This used cpp with qt for plotting map. I don't know if the same technique can be implemented under python.

I feel that pyqtgraph should have integration with earth science packages to reach to larger audience.

I came here for the reason that the package is faster and updating to the existing plot is feasible. However, it looks like it is very difficult. 

I wouldn’t say *very* difficult. I want to say that In some ways I found it to be easier to get the basics at least working with pyqtgraph than I did with Basemap (though it’s been a few months). There are libraries to do the coordinate conversions for you, so that’s easy. And subclassing axis item isn’t all that difficult either. Honestly, the map background is probably the hardest part, and (assuming you have a map you like), that’s more tweaking than anything. It might be harder if the mercator projection doesn’t work for you, however (dunno, never tried). But yes, it’s not as easy as “provide pyqtgraph your geographic data”.
Reply all
Reply to author
Forward
0 new messages