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 have a simple SpatiaLite geodb loaded in QGIS with one table. There is a POINT geometry field and some alphanumeric data. In some cases I can record data about a specific site, but the coordinates are not available at this time and will be retrieved and recorded later. In some other cases I have the coordinates and I want to insert them right into the geometry field, preferably by clicking on the map canvas in the same way available for adding new features (having a separate text field for the coordinates and generating the geometry from that is a no-go).

How do I add a geometry to an existing feature that was created with a NULL geometry field?

share|improve this question
up vote 2 down vote accepted

You can do this straight in spatialite. Run an UPDATE query each time you have the coordinates available like:

UPDATE point_table 
SET geometry=MakePoint(<your_new_x_coord>,<your_new_y_coord>, SRID)   
WHERE site_id=...;

This can be done from the spatialite_gui, or one of the QGIS database plugins. Does that help?

share|improve this answer
I should have explained that I need a GUI solution (e.g. click on a map) but maybe that can be done in one of the QGIS plugins? – steko Nov 28 '12 at 13:12
I will accept your answer and create a new question more clearly GUI-oriented. – steko Dec 7 '12 at 9:12
How ar eyou adding points to the table with a NULL geometry? I don't think that's possible in QGIS. On the other hand, you could implement a simple trigger to update the geometry column with the actual geometry whenever real x-y coordinates are added. – Micha Dec 7 '12 at 20:54
It is possible in some cases. See this other question that I posted right now. – steko Dec 8 '12 at 13:12

If you're after a GUI solution, you can use the "Add Part" tool (QGIS >=2.2 only). First, make your layer editable. Then in an Attribute Table select a single row with a null geometry that you want to add a geometry to. Back in the map canvas, select the "Add Part" tool and draw your geometry. The null geometry will be replaced by your newly drawn shape.

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.