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?

2 Answers 2

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.

2
  • 1
    In QGis 3.0.2, this tool is in Edit Menu.
    – kogexo
    Commented May 14, 2018 at 16:13
  • In 2.18 I had to make the tool visible by going to View > Toolbars > Advanced Digitizing Toolbar
    – Pocketsand
    Commented Aug 4, 2018 at 11:51
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?

3
  • 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
    Commented Nov 28, 2012 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
    Commented Dec 7, 2012 at 20:54
  • It is possible in some cases. See this other question that I posted right now.
    – steko
    Commented Dec 8, 2012 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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