1

I have the following situation:

  • Postgres database with PostGIS
  • There is a table with a PostGIS geometry column. All non geometry data is managed (create, update, delete) by a webapplication.
  • QGIS can connect to the database.

Now the idea is to have the following workflow:

  1. Create entries in the table in the webapplication. The geometry column is left empty.
  2. Use QGIS to add a polygon to the entries created in the webapplication. The polygons should be copied from a shapefile.

When I try to do this, QGIS does not allow me, to copy the polygons to an existing entry, but instead tries to insert a new entry in to the table. This is not feasible, there is some logic involved, how the non-geometry attributes need to be filled, and that logic resides in the webapplication. So I need QGIS to UPDATE an existing entry with the copied polygon.

Is this somehow possible?

  • So are you wanting to assign a geometry to an empty geometry row, i.e. the row exists but without a geometry and you want to make one. This is quite unusual as there's nothing there to edit. I'm not sure it can be done easily. If it were me I'd create a shapefile with the correct attributes, delete the empty row and copy/paste to a new row. Is there a reason why it has to be the same row? Is it joined or queried by OID? – Michael Stimson Mar 3 '16 at 5:41
  • Yes, there exists a row, without the geometry (polygon) filled in. The row contains multiple other attributes and a foreign key. The logic to create such a row is handled by the webapplication. So QGIS should just update the row, with a polygon which is copied from a shapefile. If I draw the polygon by hand in QGIS this works. Then I just select the row from PostGIS -> Toggle Editing -> Add Part -> Draw the polygon -> Save. Doing this way, QGIS updates the row, and stores the polygon to the existing Row. But the polygons come from a shapefile, as they are quite complex. – Alig Mar 3 '16 at 6:18
  • 1
    Do you need QGIS since your not drawing anything? If you have a key relating the two tables I would skip QGIS and handle everything in PostgreSQL: Upload you shapefile to the DB and join the geometry to the web controlled table or create a new table based on the join. – Jakob Mar 3 '16 at 8:12
  • Not really. On the other hand, the selection of the geometry from the shapefiles and the assignment to the row in the table is a manual process. The shapefiles might not even have the same structure. We just need to copy over the polygon to the postgres table. But I will have a look into the direct shapefile import. – Alig Mar 3 '16 at 8:40
  • Add a field to the shapefile (eg JoinID:LONG) manually assign it to the shapefile as the OID of the row that will have the geometry, that way you will have a field to join and you can follow @Jakob 's suggestion. – Michael Stimson Mar 3 '16 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.