Sunday, 18 March 2018

qgis - "CRS selector" dialog after running a script


I add an empty vector layer using the following script.


layer =  QgsVectorLayer('LineString', 'MyLayer' , 'memory')
QgsMapLayerRegistry.instance().addMapLayers([layer])

After I run the script, "Coordinate Reference System selector" dialog appear. How can I get rid of this dialog? Or, is there a script that will close the dialog?


enter image description here



Answer




You can specify the CRS when you create your memory layer:


vl = QgsVectorLayer('LineString?crs=EPSG:2964', 'MyLayer' , 'memory')

No comments:

Post a Comment