Hello everyone, I'm developping a standalone application in pyqgis in order to visualize and explore data in netcdf files. I would like to have the possibility to change the projection of basemaps ( raster in .tiff and coastal outline in vector) with the QgsGenericProjectionSelector() class but it doesn't work. I think I'm quiet close to succeed but i miss something and I don't know what. Please, does anyone can help me to resolve my problem? (I use QGis 2.10 on windows) Here is my code snippet:
self.connect(self.basemap_img, SIGNAL("clicked()"),self.on_basemapImg_triggered) self.connect(self.basemap_shp, SIGNAL("clicked()"),self.on_basemapShp_triggered) def on_basemapShp_triggered (self): statics_dir=str(self.homepath)+"/statics/ne_50m_land/" name="ne_50m_land.shp" print name ll_color=True print "ok new crs shapefile" dialog = CreateModelDialog(name, self.canvas) dialog.projSelector print "projSelector" print "ok shapefile" self.updateFileVector(statics_dir+name,ll_color) def on_basemapImg_triggered (self): statics_dir=str(self.homepath)+"/statics/NE1_HR_LC_SR/" fileName_tif="NE1_HR_LC_SR.tif" print fileName_tif dialog = CreateModelDialog(fileName_tif, self.canvas) dialog.projSelector print "projSelector" self.updatetif(statics_dir+fileName_tif) class CreateModelDialog(QDialog): def __init__(self, layer, canvas): QDialog.__init__(self) self.projSelector = QgsGenericProjectionSelector() self.projSelector.exec_() self.projSelector.selectedAuthId() self.projSelector.selectedCrsId() print self.projSelector.selectedAuthId() print "ok projection dialog box" def updatetif(self, fileName_tif): fileInfo = QFileInfo(fileName_tif) print fileInfo baseName = fileInfo.baseName() print baseName rlayer = QgsRasterLayer(fileName_tif, baseName) if not rlayer.isValid(): print "Layer failed to load!" QgsMapLayerRegistry.instance().addMapLayers([rlayer]) print "ok crs image" def updateFileVector(self,name, ll_color): self.layer2=QgsVectorLayer(name,os.path.basename(str(name)),"ogr") if not self.layer2.isValid(): print "Layer failed to load!" if ll_color : props = { 'color' : '192,192,192', 'style' : 'no', 'style' : 'solid' } s = QgsFillSymbolV2.createSimple(props) self.layer2.setRendererV2( QgsSingleSymbolRendererV2( s ) ) QgsMapLayerRegistry.instance().addMapLayers([self.layer2]) print "Add vector layer to registry" self.layers.append( QgsMapCanvasLayer(self.layer2) ) self.canvas.setLayerSet(self.layers) self.canvas.setExtent(self.layer2.extent())
_______________________________________________ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer