1

I've got a Python script which, so far, is creating a nice DEM. I need to reproject it and then run a slope analysis on it.

For the reprojection part, as I've found in a few places, I'm using gdal:warpreproject as below:

processing.run("gdal:warpreproject", 
{'INPUT':'DEM_gaussian', 
'SOURCE_CRS':None,
'TARGET_CRS':QgsCoordinateReferenceSystem('EPSG:3577'),
'RESAMPLING':1,
'NODATA':None,
'TARGET_RESOLUTION':None,
'OPTIONS':'COMPRESS=NONE|BIGTIFF=IF_NEEDED',
'DATA_TYPE':6,
'TARGET_EXTENT':None,
'TARGET_EXTENT_CRS':None,
'MULTITHREADING':False,
'EXTRA':'',
'OUTPUT':export_path})

The line breaks are mine. This normally is on a single line.

However, for some reason when doing this using the Python console it will not take into account the 'RESAMPLING':1 parameter, meaning that the resulting image isn't what I want. When I run the command manually through the toolbox and look at the history, it does and the image is perfect.

Command from the toolbox and history:

processing.run("gdal:warpreproject", {'INPUT':'C:/temp/my_dem_gaussian.sdat','SOURCE_CRS':None,'TARGET_CRS':QgsCoordinateReferenceSystem('EPSG:3577'),'RESAMPLING':1,'NODATA':None,'TARGET_RESOLUTION':None,'OPTIONS':'COMPRESS=NONE|BIGTIFF=IF_NEEDED','DATA_TYPE':6,'TARGET_EXTENT':None,'TARGET_EXTENT_CRS':None,'MULTITHREADING':False,'EXTRA':'','OUTPUT':'C:/Users/me/AppData/Local/Temp/processing_9b1c06f875804ebe9136843a5b2b393e/09bb8386582a4bd8b17f954b2518eb06/OUTPUT.tif'})

So why doesn't it take the 'RESAMPLING':1 parameter into account in my code?

EDIT and answer - not really an answer but an issue with my workflow. I was exporting one of the intermediate results to a tif, which gave me some weird hatching patterns. Instead, exporting to an sdat did the job and retained all the graphical fidelity I wanted.

4
  • What version of QGIS are you using?
    – Jake
    Jun 22 '20 at 9:03
  • @Jake version 3.4.5
    – user25730
    Jun 22 '20 at 10:02
  • @Jake Also just tried in 3.10.6 - same issue.
    – user25730
    Jun 22 '20 at 10:08
  • @Jake Got it, the issue was that I was exporting to a tif and not an sdat. Tif gave me some issues with hatching, and sdat seems to be working fine.
    – user25730
    Jun 22 '20 at 23:05
0

Quick answer - one of the files I was working on was exporting to a tif, and not an sdat. Exporting to a tif gave me some graphical hatching patterns, and an sdat seems to do the job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.