When I'm trying to batch reproject a bunch of files using GDAL warp (reproject)
from processing module in QGIS (2.14) I'm getting UnicodeEncodeError
:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 4-8: ordinal not in range(128)
Traceback (most recent call last):
File "C:/PROGRA~1/QGISES~1/apps/qgis/./python/plugins\processing\gui\BatchOutputSelectionPanel.py", line 83, in showSelectionDialog
print filename, selectedFileFilter
UnicodeEncodeError: 'ascii' codec can't encode characters in position 4-8: ordinal not in range(128)
This is a very common error when working with Russian/Unicode paths (and/or Russian locale of QGIS) and is not specific to this particular module but rather to using any Unicode paths within a workflow.
Is there any way to overcome this error?
-
1Perhaps this post might help: How can I avoid UnicodeEncodeError when using geoprocessing tools in QGIS?Joseph– Joseph2016年11月07日 11:22:03 +00:00Commented Nov 7, 2016 at 11:22
1 Answer 1
As @Joseph suggested, the problem was due to the bug in the code of the processing sub-module BatchOutputSelectionPanel.py
(maybe it exists in other modules, though I have not tested it yet).
As Traceback
suggests, the UnicodeEncodeError
comes from line 83: print filename, selectedFileFilter
. I checked the source code and have found out that variable filename
has full unicode support, but selectedFileFilter
, which stores input file mask and a mask description, has not.
e.g. in Russian locale of QGIS in this case selectedFileFilter
stores text Tif-файлы (*.tif)
and the module then tries to encode it as ascii, which causes this error.
The workaround was to switch QGIS locale to English.
Explore related questions
See similar questions with these tags.