semiautomaticgit / SemiAutomaticClassificationPlugin

https://fromgistors.blogspot.com/p/semi-automatic-classification-plugin.html
Other
136 stars 50 forks source link

SACP blocks Georeferencer in MacOS version of QGIS #189

Closed Spartacus1 closed 1 year ago

Spartacus1 commented 2 years ago

If SACP is installed, the QGIS included GDAL Georeferencer (available from Raster->Georeferencer), will not work and will crash QGIS (will hang when the progress bar appears). The only way to make it work again is to uninstall SACP completely. Cheers

semiautomaticgit commented 2 years ago

Hello, thank you for reporting this. I'll look into it.

Spartacus1 commented 2 years ago

Thank you Luca. I'll be available for testing it if needed. Best Regards

mbodnar-GS commented 2 years ago

This is also the case on Windows 10 installations, SCP must be disabled to use the Georeferencer. This appears to be something that occurs when QGIS starts and the plugin is initialized as there is a "threadsValue" line that is placed in the QGIS.ini file at start-up. A github member called 'RinceWND' described this behavior in the QGIS page.

https://github.com/qgis/QGIS/issues/46327

RinceWND commented 2 years ago

@mbodnar-GS Thank you for referencing the issue here!

I believe the culprit is the GDAL_NUM_THREADS option that is set here: https://github.com/semiautomaticgit/SemiAutomaticClassificationPlugin/blob/3e7c9f43a152b00c9ce697f783b9f602052a0383/semiautomaticclassificationplugin.py#L428 Seems like these settings are global for QGIS, and GDAL's ChunkAndWarpImage function doesn't like this specific one.

semiautomaticgit commented 2 years ago

Hello and thank you @mbodnar-GS and @RinceWND . It is a really strange issue. I'll try to fix this from the SCP side. As a workaround for using the Georeferencer, I recommend disabling SCP temporary.

Spartacus1 commented 2 years ago

I'm already doing the temporary disable trick. Hope this is a simple one to fix.

RinceWND commented 2 years ago

The funny thing is that I can't seem to reproduce the issue on an Ubuntu machine with QGIS 3.22, which I believe is installed from ppa... The georeferencer works flawlessly regardless of the plugin's threads number value. On my Windows machine I just left CPU threads value to 1 as a workaround which works for me.

Edit: I've managed to reproduce the issue with a Pop!_OS (practically Ubuntu?) machine and QGIS 3.16 installed as a flatpak. The symptoms are all the same -- georeferencer doesn't work if threadsValue is not 1. So, maybe this is an issue with GDAL that is being put into the Win/Mac/Linux packages? The Ubuntu machine mentioned above has GDAL 3.0.2 (while python console in QGIS shows 3.0.4), however the flatpak in Pop!_OS uses 3.4.0 from what I can tell (python console confirms that), while the system itself has the version 3.2.2 installed. I'm not sure if the Ubuntu's QGIS from PPA uses the system installation of GDAL or not, but it feels to me as a most likely explanation that something went wrong in GDAL itself, and this "faulty" version is now packed into the QGIS distributions. I'm not qualified for this investigation, though -- my understanding of how it all works is insufficient for learning what causes the issue at hand.

PS. Sorry for posting it here. Just needed somewhere to store my "findings" since I'll soon forget about it switching to my usual work.

roya0045 commented 2 years ago

Possibly triggering this bug https://github.com/qgis/QGIS/issues/41770

An option would be to increase the number of threads for operations that would benefit from it and the setting the number back to one. Or make the feedback handle the multithread in the georeferencer.

mc-geo-rs commented 2 years ago

I experienced this issue on Windows 10 using QGIS 3.22.0, disabling the SCP plugin and restarting QGIS fixed the issue. Posting so others like me who came from Google will know of the temporary fix.

agiudiceandrea commented 1 year ago

This is the root cause of the issue reported at: https://github.com/qgis/QGIS/issues/46327. Possibly triggering also this issue: https://github.com/qgis/QGIS/issues/50107. @semiautomaticgit, are you looking at way to fix this issue?

semiautomaticgit commented 1 year ago

Thank you for your feedback. I have changed the behavior of the SCP in version 7.10.7 to avoid the triggering of this issue.

To be clear, the Georeferencer plugin issue is not caused by the SCP. The SCP sets the GDAL configuration option GDAL_NUM_THREADS. The Georeferencer plugin has issues if this option GDAL_NUM_THREADS is greater than 1. Georeferencer plugin developers may have to fix this issue, because other plugins or users could change this option and trigger the issue in the future.