Automatically determine the driver from output file extension
Hi Daniel,
If I set the path_out
as a tif file and the fmt_out
is not set (by default ENVI) I get this error because the geoarray
think that the driver is ENVI
but not:
Warping progress |==================================================| 100.0% Complete => 0:00:01
Writing GeoArray of size (7555, 6784, 4) to /tmp/processing_NHLaRM/2a113a03f29847468fe423a1616b4df1/OUTPUT.tif.
Warning 6: driver ENVI does not support creation option WRITE_METADATA
Warning 6: driver ENVI does not support creation option WRITE_METADATA
Critical: Logged critical: Traceback (most recent call last):
File "/home/xavier/.local/share/QGIS/QGIS3/profiles/default/python/plugins/Coregistration/automated_global_coregistration_algorithm.py", line 256, in processAlgorithm
CR.correct_shifts()
File "/home/xavier/.local/share/QGIS/QGIS3/profiles/default/python/plugins/Coregistration/libs/arosics/CoReg.py", line 1723, in correct_shifts
self.deshift_results = DS.correct_shifts()
File "/home/xavier/.local/share/QGIS/QGIS3/profiles/default/python/plugins/Coregistration/libs/arosics/DeShifter.py", line 415, in correct_shifts
out_geoArr.save(self.path_out, fmt=self.fmt_out, creationOptions=self.out_creaOpt)
File "/home/xavier/.local/lib/python3.9/site-packages/geoarray/baseclasses.py", line 1086, in save
gdal.Unlink(out_path + '.aux.xml')
File "/usr/lib/python3.9/site-packages/osgeo/gdal.py", line 1682, in Unlink
return _gdal.Unlink(*args)
RuntimeError: unknown error occurred
I know that the solution is let the user define the driver with that arg, but a better solution is automatically determine the driver from output file extension, and with that, the fmt_out
is not necessary (or maybe yes but for specific cases, but by default could by auto
). There are good examples and easy to implement for that, check this (the issue and its respective PR):
https://github.com/rasterio/rasterio/issues/265 https://github.com/rasterio/rasterio/pull/2008/files