4

I have a plugin that loads a Raster image and selects the correct base maps to use. The Raster image load with no problem, but my base maps will not load.

I have create a qlr, which has 5 references. I can drop it into the Layer pane, so I know that the file is good.

What is wrong with my script?

# get a handle to the layer groups form the default project 
rootLayers = QgsProject.instance().layerTreeRoot()

 # load an group the base layers 
 vlayer = QgsVectorLayer(self.Settings.staticLayer,"static","ogr")

 # load and group the raster 
 rlayer = QgsRasterLayer(self.rasterFile.fileName(),"analysis")    


 QgsMapLayerRegistry.instance().addMapLayer(vlayer)
 rootLayers.findGroup("Static").addLayer(vlayer)
 QgsMapLayerRegistry.instance().addMapLayer(rlayer)
 rootLayers.findGroup("Analysis").addLayer(rlayer)

Browse other questions tagged or ask your own question.