1

My usual workflow with updating layer from shapefile was to:

Open DB Manager;

  1. Load SHP files into QGIS;
  2. Open DB Manager;
  3. Import file (with drop option).

Now my problem is that I have created views on data in Postgresql and I can't just drop that table any more. Now my question would be:

If I can't drop tables any more how to effectively update PostGIS layer from SHP file ?

Since this is a point layer I currently make select by location / invert to get points not included in PostGIS layer.

Is there any effective solution to automate this proces or even better is there graphical tool to update PostGIS layer from SHP maybe based on attribute join / location checking?

Thanks !

2 Answers 2

3

I finally managed to resolve my problem. My solution was to load data into temporary spatial table on PostGIS server, delete all records from table and then insert all records from temporary table to database.

DELETE FROM public.target_table;

INSERT INTO public.target_table

SELECT * FROM public.source_temporary_table;

All you need is a table with same columns and geometry type.

I hope this helps someone.

0

Would you be able to try loading your layers directly into QGIS from PostGIS? See http://docs.qgis.org/2.2/en/docs/user_manual/working_with_vector/supported_data.html#postgis-layers

2
  • I can't do that because loading same layer with same name means dropping old one and I can't do that because I have database views that depend on this table and Postgresql doasn't allow to drop table. Only possible sollution is update / insert on existing table. This mean I have to identify differences between table. Now I do this manually but it's time consuming.
    – Greg
    Jul 9, 2014 at 9:59
  • Error importing to PostGIS Creation of data source "public"."sn_vodi" failed: ERROR: cannot drop table sn_vodi because other objects depend on it DETAIL: view "SN_vodi_starost" depends on table sn_vodi HINT: Use DROP ... CASCADE to drop the dependent objects too. CONTEXT: SQL statement "DROP TABLE IF EXISTS public.sn_vodi RESTRICT" PL/pgSQL function "dropgeometrytable" line 15 at EXECUTE statement
    – Greg
    Jul 9, 2014 at 10:03

Your Answer

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

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