geoplot icon indicating copy to clipboard operation
geoplot copied to clipboard

New plot type: isopleth

Open stevenlis opened this issue 7 years ago • 10 comments

I'm so glad to see a package that makes plotting geo heatmap this kind of easy and beautiful. After reading the API and I realize that the heatmaps produced by geoplot using seaborn represent the density of geo-events. I wonder if there is any way you can think of to use interpolation method to generate those kinds of heatmaps representing air pollution, temperature, etc.

I've been looking for a way to do this kind of plot for a white.

stevenlis avatar Nov 04 '18 15:11 stevenlis

Yes, geoplot.heatmap only works on point features lacking magnitudes. If you have gridded data with magnitudes, as in the cases you mentioned, this API won't work for you.

Heatmaps based on gridded magnitude data is a generalization of heatmaps based on point data, and I'm afraid there's quite a lot of math you or I would need to chew down to work an algorithm out. I don't personally know of any way to achieve this currently in Python.

I'd recommend creating a grid of squares around each observation, and plotting that as a choropleth. You can think of this as a pixelated heatmap.

ResidentMario avatar Nov 04 '18 18:11 ResidentMario

@ResidentMario Indeed...I'm looking at this API from matplotlib and see if I can figure it out. Sadly, this heatmap thing is the only part that is missing from my complete python workflow. Thank you for your kind reply.

stevenlis avatar Nov 04 '18 21:11 stevenlis

@ResidentMario I just saw a link at the bottom of this page in the GeoPandas doc.

stevenlis avatar Nov 09 '18 23:11 stevenlis

Very cool! Maybe an implementation is easier than I thought (just reuse this component).

ResidentMario avatar Nov 10 '18 04:11 ResidentMario

@ResidentMario It would be great if there is a Python package that uses scipy interpolation module but is designed for geospatial point pattern analysis specifically like IDW and other more advanced methods.

stevenlis avatar Nov 10 '18 05:11 stevenlis

@ResidentMario Here are some good resources.

https://mathlab.github.io/PyGeM/idw.html

https://stackoverflow.com/questions/3104781/inverse-distance-weighted-idw-interpolation-with-python

https://github.com/paulbrodersen/inverse_distance_weighting

stevenlis avatar May 29 '19 23:05 stevenlis

This is known as an isopleth in the literature.

xarray seems to able to do this: http://xarray.pydata.org/en/stable/examples/monthly-means.html

ResidentMario avatar Jul 05 '19 20:07 ResidentMario

@ResidentMario The isopleth might be very useful but might not be what I was suggesting for since there are many methods for interpolation.

I just read a book this week and the author talked about a few different types of interpolation (e.g., IDW) often used in GIS in chapter 8 and shared his code here.

stevenlis avatar Jul 06 '19 00:07 stevenlis

Well, this feature request is for a plot function that takes point data with magnitudes as input, applies some sort of smoothing/interpolation function over it, and outputs a heatmap (which is an isopleth, in this context).

Interpolation can be tunable using a plot parameter. gplt.quadtree already defines an agg parameter for an aggregation function; an isopleth function could have a similar special parameter for a smoothing function whose default argument is an idw algorithm.

ResidentMario avatar Jul 06 '19 18:07 ResidentMario

as an arg? man... I think I would like such an API design and am definitely looking forward to it!

stevenlis avatar Jul 06 '19 18:07 stevenlis