I have a bunch of layers stored in PostGIS that I want to merge. I have spent quite some time investigating various approaches but I ket tripping over getting the GIDs to update properly.
In the end the only way that I found that worked was to:
- load the layers into QGIS from PostGIS and then save them as shape files in a temp dir.
- remove the layers from QGIS and reload them from the shape files.
- delete the GID attribute from the layers and save the shape files again.
- then use Vector->data managment->merge shape files to create a merged shape file
- finally use SPIT to get the merged file back into PostGIS
The purpose of this 'question' is two fold, firstly to document something at works and secondly to ask if there is a better way of doing it.
Things that I discovered on this journey:
- you can not paste features into a PostGIS layer because these don't get the appropriate magic in the GID field to allocate a new number from the sequence. (this is arguably a bug in QGIS ??)
- Splitting feature in a PostGIS layer works as it should and the new feature picks up a GID when the layer is saved.