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

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...