ubarsc / rios

A raster processing layer on top of GDAL
https://www.rioshome.org
GNU General Public License v3.0
14 stars 7 forks source link

Use gdal.Warp() rather than the gdalwarp command line program #35

Closed gillins closed 2 years ago

neilflood commented 2 years ago

I just made the UseExceptions() call the same as I have used in the rest of RIOS, to avoid interfering with the user's setting of this. (Partly I wanted to check whether I could indeed push to your PR, and it seems I can, which is good. ) Having done this, I have now seen that at some point you added an unguarded call to gdal.UseExceptions() in calcstats.py (June 2017, according to git), which clobbers all that anyway, and I am unsure whether it is required for anything else. After this PR is done, I will try to check that. GDAL is a bit stoopid for using a global variable for this, it makes it difficult to be polite.

Apart from that, I think the PR looks good. It is certainly significantly neater this way.

gillins commented 2 years ago

Thanks @neilflood - good spotting. Shame that the exceptions setting is global rather than per module that imports it...

Just pushed a change so the resetting happens in a finally clause so if an exception is raised (and caught) the resetting still happens. Let me know if you have any objections.

neilflood commented 2 years ago

Thank @gillins. Very good point, using a finally clause is much better, well done.