3

I have done it many times (clipping a raster with a polygon layer or by extension) but today I got an error for the first time and I don't know how to solve it. I am always using the same type of raster layers. When running the clipping tool I got the following message:

gdal_translate -of GTiff -ot Byte -projwin 410282.185971 4694950.41162 410783.882475 4694524.96815 -co COMPRESS=DEFLATE -co PREDICTOR=1 -co ZLEVEL=6 -co TFW=YES "C:/Users/FERRAN ALA/Desktop/Justificació Fontanals/QGIS/Topo 1_5000/bt5mv20sd0f283077st1r031.sid" "C:/Users/FERRAN ALA/Desktop/Justificació Fontanals/QGIS/background/image.tif"

GDAL command output:

'ascii' codec can't encode character u'\xf3' in position 201: ordinal not in range(128) See log for more details

Does anybody know what that is?

3
  • 2
    You should not use characters with accent mark (typical of catalan) and spaces in your paths. Probably, it is the source of your issues.
    – xunilk
    Jan 9, 2019 at 19:00
  • Please, see this link referred to unicode xf3 character: codetable.net/hex/f3
    – xunilk
    Jan 9, 2019 at 19:04
  • 1
    Hello, thank you for that information. I removed all accents and it worked perfectly. Thanks!
    – Ferran
    Jan 10, 2019 at 8:49

3 Answers 3

2

User xunilk nailed it: the error message is saying that the unicode character xf3 (which is the ó from Justificació) could not be encoded (i.e. altered from unicode to a string).

As you already figured out, remove such type of characters (with accent marks) from file paths and file names. Remove the spaces as well:

gdal_translate -of GTiff -ot Byte -projwin 410282.185971 4694950.41162 410783.882475 4694524.96815 -co COMPRESS=DEFLATE -co PREDICTOR=1 -co ZLEVEL=6 -co TFW=YES "C:/Users/FERRAN_ALA/Desktop/Justificacio_Fontanals/QGIS/Topo_1_5000/bt5mv20sd0f283077st1r031.sid" "C:/Users/FERRAN_ALA/Desktop/Justificaci0_Fontanals/QGIS/background/image.tif"
1
  • 1
    C'mon, we're not in the 90's anymore. So GDAL will never know how to use UTF-8? Who they think they are? Microsoft?!!
    – Rodrigo
    Jul 15, 2021 at 22:57
0

Maybe you use the Chinese characters, I had this problem before. And after deleting the file with Chinese characters, it run successful.

-2

## import this

conn.set_client_encoding('UTF8')

1
  • 2
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Apr 5, 2022 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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