I am using PostGIS on pgAdmin3 (PostgreSQL 9.3 e PostGIS 2.2). I have a shapefile with more than 500.000 features and I want to merge them into one.
The geometries are MultiPolygon.
I would like to have as output a shapefile with the same geometry's complexity like the input. I Have to simply the geometry after a merge...
I used several codes but none of them seem to work.
All these queries do not return what I would aspect: I have a table with the same number of feature than before.
CREATE TABLE test1 AS
SELECT gid, fid, (ST_DUMP(geom)).geom AS geom FROM land_polygons;
or
CREATE TABLE test2 AS
SELECT
1::INT as gid,
ST_Buffer(ST_Collect(geom),0)::geometry(MultiPolygon,4326)
FROM
land_polygons;
or
CREATE TABLE test3 AS
SELECT gid, fid, ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))) AS geom
FROM land_polygons
or
CREATE TABLE test4 AS SELECT ST_Union(ST_SnapToGrid(geom,0.0001)) FROM land_polygons;
I do not know what I could do more...
SELECT road_number, ST_Union(roads.wkb_geometry) as wkb_geometry FROM gis_data_highways_network.roads GROUP BY road_number ORDER BY road_number
This will sort of merge linear features (roads in my case) on values from column road_number
– Maciek Drozda Oct 12 '21 at 15:46