[GIS] Use FME to delete records from PostGIS before loading new records

fmepostgisshapefile

I have some shapefiles. Each shapefile contains the data on a topic for a county. I have data for 26 counties.

In the filename of the shapefile, the county ID is given.

I load these shapefiles into PostGIS using FME. The data for all counties is loaded into one table (so 26 shapefiles get loaded into 1 PostGIS table).

This data gets updated every now and then, and I can request the data for the county where the data has been changed. I get supplied with a new shapefile with all data for that county (not just the changed records).

I would like to delete the data in the PostGIS table for the county that I have the new data for before I load the new data.

How do I do this? Is this possible if I get the county ID from the filename of the shapefile and each record in the PostGIS table has a county ID attached to it?

My plan is to just add the new shapefile to a specified folder, and run my FME workspace.

Edit 31/05/2013

Just to clarify, I have multiple records for each county (i.e. all roads, buildings etc in a county). I basically want to bulk delete a counties data, and replace it with the new data.

Best Answer

If you have a unique county ID that is consistent with your re-supplied data then you just need to set the POSTGIS Writer to update.

enter image description here

PostGIS set to update (geometry)

enter image description here

So as long as the input shapefile is the same name you can automate the process. FME 2013 SP1 shown here.