I use this function to create layers that display results to my queries. However a dialog always pops up asking me to confirm the crs. Is it possible to suppress this ?

    def addResultLayer(name, feature, symbol, groupname):
        res_abs_path = self.getStubVectorFile()
        result_layer = QgsVectorLayer("Polygon", name, "memory")
        QgsMapLayerRegistry.instance().addMapLayer(result_layer, False)
        result_layer.dataProvider().addFeatures([feature])
        result_layer.rendererV2().setSymbol(symbol)
        result_node = QgsLayerTreeLayer(result_layer)
        self.findGroup(groupname).insertChildNode(0, result_node)
up vote 4 down vote accepted

You can provide CRS, for example:

result_layer = QgsVectorLayer("Polygon?crs=EPSG:4326", name, "memory")

If you cannot provide a CRS for new layers, as Azimo suggests, then change

Settings -> Options -> CRS

You can specify if new layers without CRS get projects CRS, a default one, or from user input. This is valid for at least QGIS version 2.8.7.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.