Pages: 1
- Sujet précédent - QGIS 3.x/PyQGIS: Impossible de charger la couche source INPUT - Sujet suivant
#1 Fri 03 July 2020 10:10
- ntouati
- Juste Inscrit !
- Date d'inscription: 14 Nov 2016
- Messages: 6
QGIS 3.x/PyQGIS: Impossible de charger la couche source INPUT
Bonjour,
Je rencontre un problème que j'arrive pas à résoudre. J'aurai besoin d'un peu d'aide.
Je travaille sur Qgis 3.10
Mon objectif est d'addition des couches raster pour ne former qu'une seule couche qui sera mobiliser pour un ré-échantillonnage (SAGA algorithme)
Voici l'extrait de mon script qui ne fonctionne pas :
Code:
#Use raster calculator to create city fraction entries = [] # initialize input list rast1 = QgsRasterCalculatorEntry() # create first raster rast1.ref = 'rast@1' # define first raster name objBuild = QgsRasterLayer(build['OUTPUT']) # get raster as QGIS object rast1.raster = objBuild # define raster rast1.bandNumber = 1 # define raster band to use entries.append(rast1) # add raster to inputs rast2 = QgsRasterCalculatorEntry() # same thing for second raster objRoad = QgsRasterLayer(road['OUTPUT']) rast2.ref = 'rast@2' rast2.raster =objRoad rast2.bandNumber = 1 entries.append(rast2) rast3 = QgsRasterCalculatorEntry() # same thing for third raster objEnv = QgsRasterLayer(env['OUTPUT']) rast3.ref = 'rast@3' rast3.raster = objEnv rast3.bandNumber = 1 entries.append(rast3) # Get a path to save outputs as temporary files getPathSave = objEmp.dataProvider().dataSourceUri() # get access path from any temporary file split1 = getPathSave.split('|') split2 = split1[0] split3 = split2[:-10] # delete file name at the end of the string # define path to save result as temporary file outputCalc = split3 + 'addition.tif' outputCalc2 = split3 + 'additionResampl.tif' calc = QgsRasterCalculator('rast@1+rast@2+rast@3', outputCalc, 'GTiff', objBuild.extent(), objBuild.width(), objBuild.height(), entries) # configure raster calculator calc.processCalculation() # launch calculation # Set raster dimensions resamplFracVille = processing.run("saga:resampling", {'INPUT': outputCalc,'KEEP_TYPE':True,'SCALE_UP':0,'SCALE_DOWN':0,'TARGET_USER_XMIN TARGET_USER_XMAX TARGET_USER_YMIN TARGET_USER_YMAX':extent, 'TARGET_USER_SIZE':resolution,'TARGET_USER_FITS':1,'TARGET_TEMPLATE':None,'OUTPUT':outputCalc2}) addFraction = iface.addRasterLayer(outputCalc2, "FRACTION_DE_VILLE")
Le script me renvoie ce message :
Code:
Incapable d’exécuter l’algorithme Impossible de charger la couche source pour INPUT: memory?geometry=Point&crs=EPSG:2154&field=Jeu:string(254,0)&field=ID:int8(10,0)&field=Nom:string(254,0)&field=Lat:double(23,15)&field=Lon:double(23,15)&field=Alt:int8(10,0)&field=Name:string(15,0)&field=_13_00_00:string(254,0)&field=_14_00_00:string(254,0)&field=_15_00_00:string(254,0)&field=_16_00_00:string(254,0)&field=_17_00_00:string(254,0)&field=_18_00_00:string(254,0)&field=_19_00_00:string(254,0)&field=_20_00_00:string(254,0)&field=_21_00_00:string(254,0)&field=_22_00_00:string(254,0)&field=_23_00_00:string(254,0)&field=_00_00_00:string(254,0)&field=_01_00_00:string(254,0)&field=_02_00_00:string(254,0)&field=_03_00_00:string(254,0)&field=_04_00_00:string(254,0)&field=_05_00_00:string(254,0)&field=_06_00_00:string(254,0)&field=_07_00_00:string(254,0)&field=_08_00_00:string(254,0)&field=_09_00_00:string(254,0)&field=_10_00_00:string(254,0)&field=_11_00_00:string(254,0)&field=_12_00_00:string(254,0)&field=_13_00_00_:string(254,0)&field=_14_00_00_:string(254,0)&field=_15_00_00_:string(254,0)&field=_16_00_00_:string(254,0)&field=_17_00_00_:string(254,0)&field=_18_00_00_:string(254,0)&field=_19_00_00_:string(254,0)&field=_20_00_00_:string(254,0)&field=_21_00_00_:string(254,0)&field=_22_00_00_:string(254,0)&field=_23_00_00_:string(254,0)&field=_00_00_00_:string(254,0)&field=_01_00_00_:string(254,0)&field=_02_00_00_:string(254,0)&field=_03_00_00_:string(254,0)&field=_04_00_00_:string(254,0)&field=_05_00_00_:string(254,0)&field=_06_00_00_:string(254,0)&field=_07_00_00_:string(254,0)&field=_08_00_00_:string(254,0)&field=_09_00_00_:string(254,0)&field=_10_00_00_:string(254,0)&field=_11_00_00_:string(254,0)&field=_12_00_00_:straddition.tif introuvable
Le problème vient-il du "split" ? ou du stockage temporaire des"outputs" ?
En vous remerciant d'avance,
N.
Dernière modification par ntouati (Fri 03 July 2020 10:10)
Hors ligne
Pages: 1
- Sujet précédent - QGIS 3.x/PyQGIS: Impossible de charger la couche source INPUT - Sujet suivant