1

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
  • Based on other forum comments, I thought possible culprits were 1. faulty installation of GDAL. or 2. The size of the raster was much too large. – Robotuner Dec 20 '15 at 2:29
  • On my windows 10 x64 machine I made sure to un-installed all instances of GDAL, bindings and python and QGIS, then I cleaned out all references to GDAL from my paths. I then reinstalled only QGIS. Still same problem. I then clipped the raster down to the minimum rectangluar size that include the lines. Still the same problem. I'm out of ideas as to what could be causing this. I also can't believe that this is a GDAL library problem. – Robotuner Dec 20 '15 at 2:35
  • Please, I will try any suggestion, this is a show stopper for me. I can't use QGIS if something like ReadAsArray leaves it in an unstable state! Oh, I can duplicate this on my laptop, and also with a different raster. – Robotuner Dec 20 '15 at 2:36
  • I tried uninstalling my 64 bit version of QGIS and installed the 32 bit version instead. Doesn't help. Get the same crash. – Robotuner Dec 22 '15 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.