I am working with os topography files which are split into points, lines and polygons. At the moment, I am trying to merge the separate files into a single topography file.
Using this source (Using PostGIS to find the overall difference between two (large) polygon datasets) I have managed to merge my polygon (test_area_2) and polyline (test_line_2) shapefiles together successfully - below.
DROP TABLE temp;
CREATE TABLE temp as (
SELECT ST_Multi(COALESCE(
ST_Difference(a.geom, c.geom),
a.geom
)) AS geom
FROM test_area_2 AS a
CROSS JOIN LATERAL (
SELECT ST_Union(b.geom) as geom
FROM test_line_2 AS b
WHERE ST_Intersects(a.geom, b.geom)
)
AS c);
However, it does not export all the associated attribute columns (i.e. test_area_2.*). I have tried different combinations to do this but so far unsuccessful.
How can I do this?