ccrook / QGIS-Contour-Plugin

Contour plugin for QGIS - uses python matplotlib to generate contours of data on vector point data.
43 stars 13 forks source link

Wrong contour lines with QGIS 3.34.6 #52

Closed phil0906 closed 2 months ago

phil0906 commented 3 months ago

I'm using the contour plugin for many years always with the same parameters. Since QGIS 3.34.6 I got wrong contour lines.

Point-Dataset: HP3.gpkg, Field with Z-Value: "Höhe" HP3.zip

Result with QGIS 3.34.6: HP3_Contours_wrong.gpkg (file size exceeds upload-limit) image image

Result with QGIS 3.34.5 and earlier: HP3_Contours_ok.gpkg (file size exceeds upload-limit) image image

Parameters for contour line [calculation:] image

ccrook commented 3 months ago

Hi Phil. Thanks for reporting this - it does not look good in 3.34.6! My Ubuntu hosted QGIS installation is at 3.36.2, so I'll check if it is still happening in that - if so then I may be able to debug. I hope to look at this in the next few days. I may need more information on your matplotlib version but will follow up here once I have looked at it.

ccrook commented 3 months ago

Hi @phil0906. I have loaded into QGIS version 3.36.2 (on Ubuntu 22.04) and it is working correctly, so odd that it isn't working in 3.34.6. I'll look at setting up 3.34.6 for testing over the next few days.

image

phil0906 commented 3 months ago

Hi Chris I just tried it within a totally new QGIS project with version 3.34.6 (only one layer "HP3"). Same error happened.

image

I'm using Windows 11. So hopefully you can reproduce the bug within your environment.

phil0906 commented 3 months ago

Hi Chris I just tried it within a totally new QGIS project with version 3.34.6 (only one layer "HP3"). Same error happened. I'm using Windows 11. So hopefully you can reproduce the bug within your environment. Best regards Philipp

Am Mi., 8. Mai 2024 um 22:14 Uhr schrieb Chris Crook < @.***>:

Hi @phil0906 https://github.com/phil0906. I have loaded into QGIS version 3.36.2 (on Ubuntu 22.04) and it is working correctly, so odd that it isn't working in 3.34.6. I'll look at setting up 3.34.6 for testing over the next few days.

image.png (view on web) https://github.com/ccrook/QGIS-Contour-Plugin/assets/631058/fdcadf57-4649-4d09-a3b6-8f60ff4b385f

— Reply to this email directly, view it on GitHub https://github.com/ccrook/QGIS-Contour-Plugin/issues/52#issuecomment-2101349601, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIKSNPHFJ3DE2FJD347SOGDZBKBQTAVCNFSM6AAAAABHK46DSOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBRGM2DSNRQGE . You are receiving this because you were mentioned.Message ID: @.***>

ccrook commented 3 months ago

Hi @phil0906. Sorry - I've been really slow on this. Just got QGIS 3.34.6 going on Ubuntu 23.10. The contouring works just fine, so still not able to replicate. The contouring plug in uses a python library, matplotlib, to calculate the contours, so that is one possible source of difference.

Please could you open the python console, then type in two commands:

import matplotlib
matplotlib.__version__

This should print the version of the library you have - I have 3.6.3.

Thanks.

phil0906 commented 3 months ago

Hi Chris I'm (resp. QGIS 3.34.6) using version '3.8.4' of matplotlib. QGIS version 3.28.11 (where everything worked fine) uses version 3.5.1

ccrook commented 3 months ago

Thanks. I think this may be related to a matplotlib API change at 3.8.0:

ContourSet is now a single Collection Prior to this release, ContourSet (the object returned by contour) was a custom object holding multiple Collections (and not an Artist) -- one collection per level, each connected component of that level's contour being an entry in the corresponding collection.

ContourSet is now instead a plain Collection (and thus an Artist). The collection contains a single path per contour level; this path may be non-continuous in case there are multiple connected components.

I should be able to fix it from this information.

phil0906 commented 3 months ago

Hi Chris Is there any chance to get this fix within the next two weeks? This would be helpful for my current project. Many thanks in advance for your answer Philipp

Am So., 19. Mai 2024 um 21:03 Uhr schrieb Chris Crook < @.***>:

Thanks. I think this may be related to a matplotlib API change at 3.8.0 https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.8.0.html :

ContourSet is now a single Collection Prior to this release, ContourSet https://matplotlib.org/stable/api/contour_api.html#matplotlib.contour.ContourSet (the object returned by contour https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.contour.html#matplotlib.axes.Axes.contour) was a custom object holding multiple Collection https://matplotlib.org/stable/api/collections_api.html#matplotlib.collections.Collections (and not an Artist https://matplotlib.org/stable/api/artist_api.html#matplotlib.artist.Artist) -- one collection per level, each connected component of that level's contour being an entry in the corresponding collection.

ContourSet https://matplotlib.org/stable/api/contour_api.html#matplotlib.contour.ContourSet is now instead a plain Collection https://matplotlib.org/stable/api/collections_api.html#matplotlib.collections.Collection (and thus an Artist https://matplotlib.org/stable/api/artist_api.html#matplotlib.artist.Artist). The collection contains a single path per contour level; this path may be non-continuous in case there are multiple connected components.

I should be able to fix it from this information.

— Reply to this email directly, view it on GitHub https://github.com/ccrook/QGIS-Contour-Plugin/issues/52#issuecomment-2119330649, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIKSNPASOAKW4ZQTQR5DKUTZDDZRJAVCNFSM6AAAAABHK46DSOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJZGMZTANRUHE . You are receiving this because you were mentioned.Message ID: @.***>

ccrook commented 3 months ago

Hi Phil. Yes ... I plan to get it done in the next few days (a convenient public holiday!). Sorry it has take so long. Just been a bit short of spare time till now.

ccrook commented 3 months ago

Hi @phil0906. Finally I think this is fixed. Please let me know if it is still not working for you. Fix is applied in pull request #53 if you are curious about the details. I fixed another issue at the same time (when opening the contour dialog with a contour layer selected it could generate an error "AttributeError: 'NoneType' object has no attribute 'sourceCrs'".

Apologies again for the long delay in getting this fixed. Just bad timing :-(

phil0906 commented 2 months ago

Hi Chris It works fine :-). Thanks for the update.

Am Mo., 3. Juni 2024 um 12:05 Uhr schrieb Chris Crook < @.***>:

Hi @phil0906 https://github.com/phil0906. Finally I think this is fixed. Please let me know if it is still not working for you. Fix is applied in pull request #53 https://github.com/ccrook/QGIS-Contour-Plugin/pull/53 if you are curious about the details. I fixed another issue at the same time (when opening the contour dialog with a contour layer selected it could generate an error "AttributeError: 'NoneType' object has no attribute 'sourceCrs'".

Apologies again for the long delay in getting this fixed. Just bad timing :-(

— Reply to this email directly, view it on GitHub https://github.com/ccrook/QGIS-Contour-Plugin/issues/52#issuecomment-2144795582, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIKSNPAL6KDYM3C65EM46ZTZFQ5VHAVCNFSM6AAAAABHK46DSOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBUG44TKNJYGI . You are receiving this because you were mentioned.Message ID: @.***>

ccrook commented 2 months ago

Great! There will be another update shortly based on my learnings from this (issue #54).