[Qgis-developer] Cleanly create memory layer in Python?

Chris Crook ccrook at linz.govt.nz
Thu Jan 6 15:16:17 EST 2011

Hi All

I'm wanting to create a memory provider in Python without invoking the CRS selection dialog (even if the QGIS settings are set to "Prompt for CRS when a new layer is created".

At the moment my code looks like:

        settings = QSettings()
        prjSetting = settings.value("/Projections/defaultBehaviour") 
        settings.setValue("/Projections/defaultBehaviour", QVariant(""))
        layer = QgsVectorLayer("point",name,"memory")
        if prjSetting:

This does work, but it seems a bit cumbersome (at first glance it doesn't even look like creating a vector layer!), so I'm wondering if there is a cleaner approach..


This message contains information, which is confidential and may be subject to legal privilege. 
If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message.
If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message.
LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ.

Thank you.

More information about the Qgis-developer mailing list