0

I've been dealing with Landlab and Python for little time, so I'm not an expert user. I was trying to run a model which purpose is to import an existing DEM into a grid, but it didn't work out. This is the code:

from landlab import RasterModelGrid 
from landlab.io import read_esri_ascii  
mg = RasterModelGrid((4852, 7894), 40) 
z = mg.add_zeros('node', 'elevation') 
(mg, z) = read_esri_ascii('DEM40_Sicilia_only_landlab.asc',name='elevation')

It gave me this error:

  File "C:\Users\claudio\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 202: character maps to <undefined>

Does anyone know the answer to solve my problem?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 2
    Please show the rest of the traceback. – Daniel Roseman Feb 22 '18 at 10:17
  • 2
    Usually that means the file encoding isn't what you expect, see e.g. https://stackoverflow.com/questions/9233027/unicodedecodeerror-charmap-codec-cant-decode-byte-x-in-position-y-character – jonrsharpe Feb 22 '18 at 10:19
  • I've discovered that, in QGIS, the conversion from .tif format to .asc format of the DEM didn't work out. So, when I opened the .asc file with a text editor, it was full of strange characters, instead of the actual height values. I've solved the problem by using ArcMap to make that conversion and with the same script I managed to do it eventually. – Giuseppe Cipolla Feb 23 '18 at 08:35

0 Answers0