I've got 100+ shapefiles of contours with the following fields:
And I need to upload them into a single table in PostgreSQL.
Now, I've managed to upload about 50 of them using QGIS and pgAdmin III. I'll upload them each as their own table using QGIS' DB Manager, and then using pgAdmin III I'll run an insert query to simply tag it onto the end.
The trouble is, the other 50 shapefiles overlap with other shapes I've uploaded. The ones already uploaded are fine - no overlaps - but the remaining 50 all need some amending so we're not doubling up on features. For instance, one shapefile may be directly next to another that's already been inserted, and the two slightly overlap.
I would imagine using an ST_Difference would do this but I'm having trouble with the syntax, as well as preserving the data. There is also some difficulty with the size of the data that's already in there (500,000+ records).
I should mention that the geometry in question is linestring.
Currently I think I'm looking at having to chop this all down manually, which will be pretty time-consuming, and was wondering if anyone would post an example of using ST_Difference with two tables in order to chop table A down so that it doesn't include anything from table B, but still preserve the class and altitude?
EDIT - Alternatively, if anyone knows how to make polygons out of linestrings/polylines (so essentially we get an "outline" of the shapefile coverage) that would be great, as I could just generate and clip on them locally. I did experiment with concave hull, will have to try that again. It always stopped at the end (currently using QGIS 2.18.13).