Hello,
I am trying to understand how to easily loop through the values of a
raster layer using pyqgis.
In the docs I see the sample and identify methods of the dataprovider,
but can't spot anything that uses rows/cols as a way of iteration.
Is the most efficient way to use transformCoordinates to get the world
coordinates and then use the sample function?
Something like this:
cols = dtmLayer.width();
rows = dtmLayer.height();
transformType = QgsRasterDataProvider.TransformType.TransformImageToLayer
for row in range(rows):
for col in range(cols):
point =
dtmLayer.dataProvider().transformCoordinates(QgsPoint(col, row),
transformType)
value, res =
dtmLayer.dataProvider().sample(QgsPointXY(point.x(), point.y()), 1)
The above for some reason doesn't work yet though.
Thanks,
Andrea
_______________________________________________
QGIS-User mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user