13

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?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
steko
  • 719
  • 5
  • 25

2 Answers2

20

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.

ndawson
  • 27,620
  • 3
  • 61
  • 85
3

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?

Micha
  • 15,555
  • 23
  • 29
  • 1
    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
  • 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 07 '12 at 20:54
  • It is possible in some cases. See this other question that I posted right now. – steko Dec 08 '12 at 13:12