bartromgens / geojsoncontour

Convert matplotlib contour plots to geojson
MIT License
90 stars 31 forks source link

Right-hand rule polygons not followed with most recent matplotlib versions #24

Open AugustinMortier opened 11 months ago

AugustinMortier commented 11 months ago

Hello from Norway ! It looks like, since matplotlib 3.8.?, the geojson files computed with geojsoncontour are not always following the right-hand rule. This was probably taken care of by matplotlib before, but recent release notes suggest some "revert contour" deprecation.

bartromgens commented 4 months ago

https://pypi.org/project/geojson-rewind/ seems to be able to rewind geojson polygons. Could be used to fix this, or provide tips on how to fix this.

bertcoerver commented 4 months ago

When using geojsoncontour.contour_to_geojson on contours created by plt.contour from matplotlib>=3.8.0, different isolines (with same values) were connected together for my usecase:

Screenshot 2024-07-12 at 14 20 53

After downgrading to matplotlib==3.7.3, the output from geojsoncontour.contour_to_geojson is normal again:

Screenshot 2024-07-12 at 14 21 10
maxdow commented 4 months ago

They are some breaking changes concerning contourf method in the 3.8 release of matplotlib https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.8.0.html#contourset-is-now-a-single-collection

toddscottik commented 1 month ago

When using geojsoncontour.contour_to_geojson on contours created by plt.contour from matplotlib>=3.8.0, different isolines (with same values) were connected together for my usecase:

Screenshot 2024-07-12 at 14 20 53

After downgrading to matplotlib==3.7.3, the output from geojsoncontour.contour_to_geojson is normal again:

Screenshot 2024-07-12 at 14 21 10

I made a fix for it, here is my PR #26 Matplotlib still allows you to have an access to each closed contour in contour.allsegs field, while contour.get_paths() contains a single Path for each level. I understand, there is a room for improvement, maybe it's better to get only one feature for every level instead of one feature for each closed contour.