2

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?

1

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.