I have a raster layer and two points with their coordinates, and I want to find the maximum raster value on the line between these two points.
Is there a built-in function in PyQGIS to find the pixel with the maximum value between those points (and optionally retrieve its coordinates) ?
I'm extracting the pixel value for a point with
raster.dataProvider().sample(QgsPointXY(x, y), 1), so I was thinking maybe
raster.dataProvider().sample(QgsLineString(QgsPointXY(x1, y1), QgsPointXY(x2, y2)), 1) would do it, but I get an error :
TypeError: QgsRasterDataProvider.sample(): argument 1 has unexpected type 'QgsLineString'
Is there an easy way to do this?
Edit: I'm doing this by dividing the transect in x points and calculating the raster value for each, but a PyQGIS function could do it better/faster I suppose.