pyQGIS supress CRS dialog

As per:
http://pyqgis.blogspot.co.nz/2012/10/basics-automatic-use-of-crs-for-new.html
from PyQt4.QtCore import QSettings
s = QSettings()
oldValidation = s.value( "/Projections/defaultBehaviour")
s.setValue( "/Projections/defaultBehaviour", "useGlobal" )
vlayer = QgsVectorLayer("importfilename.shp", "layer name", "ogr")
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
vlayer.setCrs( QgsCoordinateReferenceSystem(4326, QgsCoordinateReferenceSystem.EpsgCrsId) )
s.setValue( "/Projections/defaultBehaviour", oldValidation )

Or to force dialog back again:

from PyQt4.QtCore import QSettings
s=QSettings()
s.setValue( "/Projections/defaultBehaviour", "prompt" )

Leave a Reply

Your email address will not be published. Required fields are marked *


× seven = 7