Using processing.runandload in QGIS 3

I think with the new QGIS 3.0, it is much easier to incorporate the input parameters of an algorithm into a dictionary which can then be called using:

processing.runAndLoadResults()

which is the equivalent to the QGIS <= 2.18 version:

processing.runandload()

So your code could look like:

import processing
rasterLyr = QgsRasterLayer("C:/Users/Mustafa Uçar/Desktop/Tutorial/qgis_data/dem/dem.asc", "hillshade")
rasterLyr.isValid()

parameters = {'INPUT': rasterLyr, 
                'BAND': 1, 
                'COMPUTE_EDGES': False,
                'ZEVENBERGEN': False,
                'Z_FACTOR': 1.0,
                'SCALE': 1.0,
                'AZIMUTH': 315,
                'ALTITUDE': 45,
                'OUTPUT': "C:/Users/Mustafa Uçar/Desktop/Tutorial/qgis_data/dem/hillshade.tif"}

processing.runAndLoadResults('gdal:hillshade', parameters)

Note that gdalogr:hillshade is now currently gdal:hillshade.


I followed @Joseph directions and it helps me to see another visions. I opened processing toolbox in QGIS and complete missing parameters. Here is the last version:

import processing   
rasterLyr = QgsRasterLayer("C:/qgis_data/dem/dem.asc", "Hillshade")
rasterLyr.isValid()

parameters = {'INPUT': rasterLyr, 
                'BAND': 1, 
                'COMPUTE_EDGES': False,
                'ZEVENBERGEN': False,
                'Z_FACTOR': 1.0,
                'SCALE': 1.0,
                'AZIMUTH': 315,
                'COMBINED': False,
                'ALTITUDE': 45,
                'MULTIDIRECTIONAL': False,
                'OUTPUT': "C:/qgis_data/dem/hillshade.tif"}

processing.runAndLoadResults('gdal:hillshade',parameters)