<div dir="ltr"><div><div><div>Hello everyone,<br><br></div>I'm developping a standalone application in pyqgis in order to visualize and explore data in netcdf files.<br></div>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.<br></div><div>Please, does anyone can help me to resolve my problem?<br></div><div>(I use QGis 2.10 on windows)<br></div>Here is my code snippet:<br><br>self.connect(self.basemap_img, SIGNAL("clicked()"),self.on_basemapImg_triggered)<br>self.connect(self.basemap_shp, SIGNAL("clicked()"),self.on_basemapShp_triggered)<br><br>def on_basemapShp_triggered (self):<br>Â Â Â Â Â Â Â statics_dir=str(self.homepath)+"/statics/ne_50m_land/"<br>Â Â Â Â Â Â Â name="ne_50m_land.shp"<br>Â Â Â Â Â Â Â print name<br>Â Â Â Â Â Â Â ll_color=True<br>Â Â Â Â Â Â Â print "ok new crs shapefile"<br>Â Â Â Â Â Â Â dialog = CreateModelDialog(name, self.canvas)<br>Â Â Â Â Â Â Â dialog.projSelector<br>Â Â Â Â Â Â Â print "projSelector"<br>Â Â Â Â Â Â Â print "ok shapefile"<br>Â Â Â Â Â Â Â self.updateFileVector(statics_dir+name,ll_color)<br><br>Â def on_basemapImg_triggered (self):<br>Â Â Â Â Â Â Â statics_dir=str(self.homepath)+"/statics/NE1_HR_LC_SR/"<br>Â Â Â Â Â Â Â fileName_tif="NE1_HR_LC_SR.tif"<br>Â Â Â Â Â Â Â print fileName_tif<br>Â Â Â Â Â Â Â dialog = CreateModelDialog(fileName_tif, self.canvas)<br>Â Â Â Â Â Â Â dialog.projSelector<br>Â Â Â Â Â Â Â print "projSelector"<br>Â Â Â Â Â Â Â self.updatetif(statics_dir+fileName_tif)<br><br>class CreateModelDialog(QDialog):<br>Â Â Â def __init__(self, layer, canvas):<br>Â Â Â Â Â Â Â QDialog.__init__(self)<br>Â Â Â Â Â Â Â self.projSelector = QgsGenericProjectionSelector()<br>Â Â Â Â Â Â Â self.projSelector.exec_()<br>Â Â Â Â Â Â Â self.projSelector.selectedAuthId()<br>Â Â Â Â Â Â Â self.projSelector.selectedCrsId()<br>Â Â Â Â Â Â Â print self.projSelector.selectedAuthId()<br>Â Â Â Â Â Â Â print "ok projection dialog box"<br><br>def updatetif(self, fileName_tif):<br>Â Â Â Â Â Â Â fileInfo = QFileInfo(fileName_tif)<br>Â Â Â Â Â Â Â print fileInfo<br>Â Â Â Â Â Â Â baseName = fileInfo.baseName()<br>Â Â Â Â Â Â Â print baseName<br>Â Â Â Â Â Â Â rlayer = QgsRasterLayer(fileName_tif, baseName)<br>Â Â Â Â Â Â Â if not rlayer.isValid():<br>Â Â Â Â Â Â Â Â Â Â Â print "Layer failed to load!"<br>Â Â Â Â Â Â Â QgsMapLayerRegistry.instance().addMapLayers([rlayer])<br>Â Â Â Â Â Â Â print "ok crs image"<br>Â Â Â <br>Â Â Â def updateFileVector(self,name, ll_color):<br>Â Â Â Â Â Â Â self.layer2=QgsVectorLayer(name,os.path.basename(str(name)),"ogr")Â Â <br>Â Â Â Â Â Â Â if not self.layer2.isValid():<br>Â Â Â Â Â Â Â Â Â Â Â print "Layer failed to load!"<br>Â Â Â Â Â Â Â if ll_color :<br>Â Â Â Â Â Â Â Â Â Â Â props = { 'color' : '192,192,192', 'style' : 'no', 'style' : 'solid' }<br>Â Â Â Â Â Â Â Â Â Â Â s = QgsFillSymbolV2.createSimple(props)<br>Â Â Â Â Â Â Â Â Â Â Â self.layer2.setRendererV2( QgsSingleSymbolRendererV2( s ) )<br>Â Â Â Â Â Â Â QgsMapLayerRegistry.instance().addMapLayers([self.layer2])<br>Â Â Â Â Â Â Â print "Add vector layer to registry"<br>Â Â Â Â Â Â Â self.layers.append( QgsMapCanvasLayer(self.layer2) )<br>Â Â Â Â Â Â Â self.canvas.setLayerSet(self.layers)<br>Â Â Â Â Â Â Â self.canvas.setExtent(self.layer2.extent())<br>Â Â Â Â Â Â <br></div>