I'm trying to get a raster from a DSM running the following code from python libraries osgeo-gdal in python qgis console:
import pandas as pd
from osgeo import gdal
df = pd.read_csv(azimut_altitude.csv')
src_ds = gdal.Open(my_raster.tif')
#array generation function
def shade_array (index):
out = r'.\my_path\raster'
azimut = df.azimut[index]
altitude = df.altitude[index]
data = gdal.DEMProcessingOptions(options = [],
colorFilename=None,
format="GTiff",
creationOptions=None,
computeEdges=False,
alg='Horn',
band=1,
zFactor=None,
scale=None,
azimuth=azimut,
altitude=altitude,
combined=False,
multiDirectional = False,
slopeFormat=None,
trigonometric=False,
zeroForFlat=False,
addAlpha=None,
callback=None,
callback_data=None)
shade = gdal.DEMProcessing(out + str(index), src_ds, 'hillshade')
return shade
shade_array(0)
The problem is that when I run the script it yields this message:
ValueError: Received a NULL pointer.
I've tried to solve introducing the input file as an array but then the error message is this:
TypeError: in method 'DEMProcessingInternal', argument 2 of type 'GDALDatasetShadow *'