[Qgis-developer] how to add crs to a new memory provider layer?

Ricardo Filipe Soares Garcia da ricardo.garcia.silva at gmail.com
Fri Aug 6 18:00:03 EDT 2010


Hi list
I'm trying to create a plugin that creates a new layer using the
memory provider. I'd like this new layer to have the same crs as
another layer ('linesLayer' in my code below). All is going well,
except that when I add the new layer to the mapLayerRegistry I always
get prompted for selecting the new layer's crs. So, how do I go about
defining it programatically? What I want is to not be bothered with
the dialog to select my layer's crs during the execution of the
plugin. Currently I am doing:

# python code
pointLayer = QgsVectorLayer("Point", "temporary_points", "memory")
pointLayer.setCrs(linesLayer.crs())
# rest of the code
self.layerRegistry.addMapLayer(pointLayer)


Thank you

p.s. - I have been following the examples at the pyqgis cookbook[1]
and I think it is a great learning tool!


[1] - http://mapserver.sk/~wonder/qgis/html/index.html

-- 
___________________________ ___ __
Ricardo Garcia Silva


More information about the Qgis-developer mailing list