Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a memory layer, I followed the directions from the page below but no points appeared on my map. First I tried typing each line into the python console and I also create a plugin with the same code and still nothing appeared on the map. At some point while I was typing the code into the console, it asked for the projection, so I specified my typical projection (epsg 2272, a state plane coordinate system)

How to create a new empty vector layer programmatically?

I also reviewed

I am experimenting with memory layers because I want to include it into a plugin I am developing.

share|improve this question
Please provide your script so far – underdark Nov 15 '12 at 14:42

I needed to add the layer to the interface using:


from PyQt4.QtCore import *

vl = QgsVectorLayer("Point", "temporary_points", "memory")
pr = vl.dataProvider()
pr.addAttributes( [ QgsField("name", QVariant.String), QgsField("age",  QVariant.Int),    QgsField("size", QVariant.Double) ] )

fet = QgsFeature()
fet.setGeometry( QgsGeometry.fromPoint(QgsPoint(1260179,432083)) )
fet.setAttributeMap( { 0 : QVariant("Johny"), 1 : QVariant(20), 2 : QVariant(0.3) } )
pr.addFeatures( [ fet ] )
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.