I'm trying to access a previously created temporary raster output with gdalnumeric.LoadFile()
to calculate some statistics. It seems to me that gdalnumeric.LoadFile()
can only access a file through a file path and not with a QGIS temporary output.
I tried without success:
import gdalnumeric
path="C:\Users\...\xxx.gpkg"
raster = processing.run("gdal:rasterize", {'INPUT':path,'FIELD':'','BURN':1,'UNITS':1,'WIDTH':50,'HEIGHT':50,'EXTENT':'32351398.3019399,32593108.6666274,5366514.87416986,6045057.7298552 [EPSG:5652]','NODATA':0,'OPTIONS':'','DATA_TYPE':0,'INIT':None,'INVERT':False,'EXTRA':'','OUTPUT':'TEMPORARY_OUTPUT'})
raster_file = raster['OUTPUT']
Is there a way to access the temporary raster with gdalnumeric.LoadFile()
? Or do I need to use a QGIS native algorithm to continue my analysis?
1 Answer 1
Why don't you change 'OUTPUT':'TEMPORARY_OUTPUT'
to 'OUTPUT':'/tmp/myfile.tif'
and then use gdalnumeric.LoadFile()
on it?
-
TEMPORARY_OUTPUT
is portable and takes care of working in an appropriate path and with unique filenames.bugmenot123– bugmenot1232023年03月12日 15:34:15 +00:00Commented Mar 12, 2023 at 15:34