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.

Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
asked Jun 22, 2020 at 7:29
4
  • What version of QGIS are you using? Commented Jun 22, 2020 at 9:03
  • @Jake version 3.4.5 Commented Jun 22, 2020 at 10:02
  • @Jake Also just tried in 3.10.6 - same issue. Commented Jun 22, 2020 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. Commented Jun 22, 2020 at 23:05

1 Answer 1

1

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.

answered Jun 22, 2020 at 23:07

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.