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?

asked Nov 2, 2016 at 9:36
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.

answered Nov 7, 2016 at 13:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.