[Gfoss] QGIS - COST RASTER (r.cost) ERROR

Luca Delucchi lucadeluge a gmail.com
Gio 22 Nov 2018 08:14:04 CET


On Wed, 21 Nov 2018 at 15:50, francesco.fiermonte a polito.it
<francesco.fiermonte a polito.it> wrote:
>
> Ciao a Tutti,
>

ciao,

> per un progetto sulla Walkability dobbiamo utilizzare analisi "cost raster" e "cost distance".
>
> Utilizzando le ultime versioni di QGIS (64 bit, 3.4.1-1 oppure 2.18.25.1, standalone, @Windows.10) all'utilizzo di "r.cost" l'applicativo si blocca restituendo un msg di errore:
>
> ************************************************
> Algoritmo in esecuzione...
> Algorithm 'r.cost' starting…
> Parametri in ingresso:
> { '-k' : False, '-n' : True, 'GRASS_MIN_AREA_PARAMETER' : 0.0001, 'GRASS_RASTER_FORMAT_META' : '', 'GRASS_RASTER_FORMAT_OPT' : '', 'GRASS_REGION_CELLSIZE_PARAMETER' : 1, 'GRASS_REGION_PARAMETER' : None, 'GRASS_SNAP_TOLERANCE_PARAMETER' : -1, 'input' : 'K:/VICO/COSTRASTER.tif', 'max_cost' : 0, 'memory' : 300, 'nearest' : 'C:/(path)/AppData/Local/Temp/processing_73cae44918f44fe695681873548e2040/22e867a27daa41028bd955733f334485/nearest.tif', 'null_cost' : None, 'outdir' : 'C:/(path)/AppData/Local/Temp/processing_73cae44918f44fe695681873548e2040/88a35e034a654ef08adbaea2827e27a6/outdir.tif', 'output' : 'C:/(path)/AppData/Local/Temp/processing_73cae44918f44fe695681873548e2040/fed16efff43841378f8fc79b14f001a3/output.tif', 'start_coordinates' : None, 'start_points' : None, 'start_raster' : 'K:/(nome_file).tif', 'stop_coordinates' : None, 'stop_points' : None }
>
> g.proj -c proj4="+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68 +units=m +no_defs"
> r.external input="K:\COSTRASTER.tif" band=1 output="rast_5bf53e5abaf9f2" --overwrite -o
> r.external input="K:\Fermate_linee_forza_rast10.tif" band=1 output="rast_5bf53e5abaf9f3" --overwrite -o
> g.region n=4990786.76951 s=4988351.7695078775 e=1397086.140802873 w=1395328.1408 res=1.0
> r.cost input=rast_5bf53e5abaf9f2 -n start_raster=rast_5bf53e5abaf9f3 max_cost=0 memory=300 output=output5457737a0bf84a42bb737ed6a5285dce nearest=nearest5457737a0bf84a42bb737ed6a5285dce outdir=outdir5457737a0bf84a42bb737ed6a5285dce --overwrite
> g.region raster=output5457737a0bf84a42bb737ed6a5285dce
> r.out.gdal -t -m input="output5457737a0bf84a42bb737ed6a5285dce" output="C:\(path)\AppData\Local\Temp\processing_73cae44918f44fe695681873548e2040\fed16efff43841378f8fc79b14f001a3\output.tif" format="GTiff" createopt="TFW=YES,COMPRESS=LZW" --overwrite
> g.region raster=nearest5457737a0bf84a42bb737ed6a5285dce
> r.out.gdal -t -m input="nearest5457737a0bf84a42bb737ed6a5285dce" output="C:\(path)\AppData\Local\Temp\processing_73cae44918f44fe695681873548e2040\22e867a27daa41028bd955733f334485\nearest.tif" format="GTiff" createopt="TFW=YES,COMPRESS=LZW" --overwrite
> g.region raster=outdir5457737a0bf84a42bb737ed6a5285dce
> r.out.gdal -t -m input="outdir5457737a0bf84a42bb737ed6a5285dce" output="C:\(path)\AppData\Local\Temp\processing_73cae44918f44fe695681873548e2040\88a35e034a654ef08adbaea2827e27a6\outdir.tif" format="GTiff" createopt="TFW=YES,COMPRESS=LZW" --overwrite
> Sto avviando GRASS GIS...
> Traceback (most recent call last):
> File "E:/QGIS_3.4.1-1/apps/qgis/./python/plugins\processing\algs\grass7\Grass7Algorithm.py", line 415, in processAlgorithm
> Grass7Utils.executeGrass(self.commands, feedback, self.outputCommands)
> File "E:/QGIS_3.4.1-1/apps/qgis/./python/plugins\processing\algs\grass7\Grass7Utils.py", line 372, in executeGrass
> for line in iter(proc.stdout.readline, ''):
> File "E:\QGIS_3.4.1-1\apps\Python37\lib\codecs.py", line 322, in decode
> (result, consumed) = self._buffer_decode(data, self.errors, final)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe8 in position 50: invalid continuation byte
>
> Esecuzione fallita dopo 1.62 secondi
> ************************************************
>
> Sembrerebbe che il problema sia causato da "errate codifiche":
>

si guardando così al volo potrebbe essere:
- o un problema di python3 (di qgis) che prova a comunicare con
python2 (di GRASS) [non so come viene implementato GRASS in
processing]
- un problema con i tuoi dati che contengono qualche carattere strano

> https://gis.stackexchange.com/questions/302457/qgis-3-4-error-utf-8-codec-cant-decode-byte-0xe8-in-position-50-invalid-cont/302526#302526
>
> Purtroppo, anche seguendo i suggerimenti proposti, non se ne viene a capo.
>
> Suggerimenti?
>

proverei ad utilizzare qgis 2.18 che supporta ancora python2 oppure
usare direttamente GRASS senza passare da qgis.

> Vi ringrazio.
>
> Ciao,
> Francesco.
>

-- 
ciao
Luca

www.lucadelu.org


Maggiori informazioni sulla lista Gfoss