In QGIS 2.XX, the drop-down menu bar tools had an editable call box at the bottom, where commands not available in the gui could be manually entered (by clicking a pencil button). In 3.0, the menu bar tools are the same as the GDAL tools found in the processing toolbox, which makes more sense, but now I do not see a way to add simple commands to a tool operation. The example I attach is the warp (reproject)
tool, I wish to add the command "-wo CUTLINE_ALL_TOUCHED=TRUE
". How do I do that?
-
Don't think you can at the moment. There is a feature request for this (I assume you are the same person who wrote the comment in the link?). You can add creation options but not warp options from the GUI.– JosephCommented Mar 6, 2018 at 11:01
-
3Yup, that was me. So now the only way to add additional commands is through the python console? Seems rather a regression for QGIS, the focus should be on the gui, I can do script-based commands easier in R– user77942Commented Mar 7, 2018 at 12:52
-
1This is a crying shame. I see the feature request has been made a few times and rejected. You are right this is a retrograde step as it was so convenient to tweak a GDAL command - which was often necessary as the defaults are often not correct (just now I wanted a Byte output instead of Float32 from a clip process - and now I have to do two steps instead of one).– MappaGnosisCommented Sep 12, 2018 at 16:07
-
A shame to see that a year later in QGIS 3.4.2-Madeira I am facing the same problem– MarcoCommented Mar 6, 2019 at 9:13
4 Answers
This can be done using Python console.
First copy (or write) a GDAL command and edit in a text viewer. For instance:
gdaldem hillshade C:/MyInputFile.tif C:/MyOutputFile.tif -of GTiff -b 1 -z 1.0 -s 1.0 -az 315.0 -alt 45.0 -multidirectional
, where we need to delete -az 315.0
(cannot do it in the interface...)
Then open the Python console and type:
import subprocess
cmd = "gdaldem hillshade C:/MyInputFile.tif C:/MyOutputFile.tif -of GTiff -b 1 -z 1.0 -s 1.0 -alt 45.0 -multidirectional"
subprocess.run ([x for x in cmd.split(" ") if x != ""])
Command cmd
has to be enclosed with quotation marks " ". Note that you will need to load manually the created file.
I agree that disabling editing of gdal commands is a retrograde step - hope it gets implemented in future versions.
Disappointing that you can't edit GDAL commands easily in latest QGIS. One option is to use the OSGeo4W shell that installs along with QGIS. You can use that to run GDAL commands directly.
-
Open this from the Start menu: Start > QGIS 3.x > OSGeo4W shell– vinhCommented Oct 15, 2019 at 13:43
-
I guess people who install using the QGIS-only installer rather than through OSGeo4W don't have this available, though (I'm not sure). Commented Oct 15, 2019 at 19:56
A simple and easy to follow user guide for installing GDAL by UCLA Installing GDAL for Windows It is great for running custom GDAL straight from the command prompt.
A way to do it is to run a dummy command with most of the parameter that you want to keep and then check the history of your processing toolbox. You will find a line like the one below:
processing.run("gdal:warpreproject", {'INPUT':'C:/Users/XXXXX/DTM_300X.tif','SOURCE_CRS':QgsCoordinateReferenceSystem('EPSG:300X'),'TARGET_CRS':QgsCoordinateReferenceSystem('EPSG:300Y'),'RESAMPLING':0,'NODATA':None,'TARGET_RESOLUTION':None,'OPTIONS':'','DATA_TYPE':0,'TARGET_EXTENT':None,'TARGET_EXTENT_CRS':None,'MULTITHREADING':False,'EXTRA':'','OUTPUT':'C:/Users/XXXXX/DTM_300Y.tif'})
You can copy and paste it in in an text editor for your modification and once it is ready, you can run it in the Python console of QGIS.
Would it be 'OPTIONS':'-wo'
? I did not try it