I have a QGIS plugin that reads a raster to get the elevation at vertex points in a polyline. The issue is that even though a single call to ReadAsArray(…) appears to work, if I immediately exit QGIS, A Crash Dump dialog appears. What is wrong with the way I making the call?
def run(self):
# show the dialog
self.dlg.show()
# Run the dialog event loop
result = self.dlg.exec_()
# See if OK was pressed
if result:
selectedVectorLayer = self.getSelectedVectorLayer()
selectedRasterLayer = self.getSelectedRasterLayer()
if self.validateSelectedLayers(selectedVectorLayer,selectedRasterLayer) is False:
return;
gdal.AllRegister()
ds = gdal.Open(selectedRasterLayer.source(), GA_ReadOnly)
if ds is None:
QgsMessageLog.logMessage(selectedRasterLayer.source() + ' not found!', 'LineSlopes', QgsMessageLog.WARNING)
return
dataPoint = ds.GetRasterBand(1).ReadAsArray(122, 149, 1, 1)
del ds