I'm using QGIS 2.8, currently developing a python plugin and at some point I have to execute consecutive processing algorithms. When it comes to loading the layer created by GDAL algorithm 'Clip raster by mask layer', I get an error. My code is like this:
processing.runalg('gdalogr:cliprasterbymasklayer', DEM, str_plgnz_int, None, None, None, None, dem_clipper) processing.load(dem_clipper) processing.runalg('saga:gridstatisticsforpolygons', dem_clipper, a_basins, False, True, True, True, False, True, True, False, None, basin_stats) processing.load(basin_stats) When trying to load 'dem_clipper' I get the following python error:
File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\tools\dataobjects.py", line 191, in load + '\nCheck the procesing framework log to look for errors') RuntimeError: Could not load layer: C:\Users\...\dem_clipper.shp And If I don't load the layer and just go straight to the next algorithm with dem_clipper as input, then I get this error:
File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\core\GeoAlgorithm.py", line 410, in checkInputCRS crs = dataobjects.getObject(item).crs() AttributeError: 'NoneType' object has no attribute 'crs' However if I manually load the layer in QGIS, everything is fine and I can use the layer in other algorithms whithout problems (even though the 'layer original source projection' in metadata is different from the other rasters). Manually in QGIS I do the same thing with the clipper (which I suppose I can't use in the plugin..?) and I think that it has the same problem with the output crs, although it doesn't create any problems (both algorithms are fine when called from the toolbox). Sorry for the long post. Any help would be greatly appreciated.
أكثر...
processing.runalg('gdalogr:cliprasterbymasklayer', DEM, str_plgnz_int, None, None, None, None, dem_clipper) processing.load(dem_clipper) processing.runalg('saga:gridstatisticsforpolygons', dem_clipper, a_basins, False, True, True, True, False, True, True, False, None, basin_stats) processing.load(basin_stats) When trying to load 'dem_clipper' I get the following python error:
File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\tools\dataobjects.py", line 191, in load + '\nCheck the procesing framework log to look for errors') RuntimeError: Could not load layer: C:\Users\...\dem_clipper.shp And If I don't load the layer and just go straight to the next algorithm with dem_clipper as input, then I get this error:
File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\core\GeoAlgorithm.py", line 410, in checkInputCRS crs = dataobjects.getObject(item).crs() AttributeError: 'NoneType' object has no attribute 'crs' However if I manually load the layer in QGIS, everything is fine and I can use the layer in other algorithms whithout problems (even though the 'layer original source projection' in metadata is different from the other rasters). Manually in QGIS I do the same thing with the clipper (which I suppose I can't use in the plugin..?) and I think that it has the same problem with the output crs, although it doesn't create any problems (both algorithms are fine when called from the toolbox). Sorry for the long post. Any help would be greatly appreciated.
أكثر...