[Qgis-developer] Cleanly create memory layer in Python?
wonder.sk at gmail.com
Fri Jan 7 13:05:57 EST 2011
On Thu, Jan 6, 2011 at 9:16 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> 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..
I agree this is cumbersome. A possible solution would be to extend the
URI for memory provider - currently it accepts only a string with
geometry type. New syntax could be introduced that would explicitly
set layer CRS, e.g. "geometry=point&crs=4326". Any thoughts and
patches are welcome.
More information about the Qgis-developer