pyQGIS supress CRS dialog

As per:
from PyQt4.QtCore import QSettings
s = QSettings()
oldValidation = s.value( "/Projections/defaultBehaviour")
s.setValue( "/Projections/defaultBehaviour", "useGlobal" )
vlayer = QgsVectorLayer("importfilename.shp", "layer name", "ogr")
vlayer.setCrs( QgsCoordinateReferenceSystem(4326, QgsCoordinateReferenceSystem.EpsgCrsId) )
s.setValue( "/Projections/defaultBehaviour", oldValidation )

Or to force dialog back again:

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

Leave a Reply

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

× seven = 7