2

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?

Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
asked Jul 22, 2020 at 9:50

1 Answer 1

0

Why don't you change 'OUTPUT':'TEMPORARY_OUTPUT' to 'OUTPUT':'/tmp/myfile.tif' and then use gdalnumeric.LoadFile() on it?

answered Jul 24, 2020 at 9:51
1
  • TEMPORARY_OUTPUT is portable and takes care of working in an appropriate path and with unique filenames. Commented Mar 12, 2023 at 15:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.