2

This question already has an answer here:

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...

marked as duplicate by Get Spatial, Andre Silva, HDunn, PolyGeo Nov 21 '16 at 21:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Please edit the question to specify the geometry type of the features (point/line/polygon) and the geometry type of the desired result (your SQL suggests many different possibilities). If it's polygons with which you are working, what is the quality of the boundaries (to prevent massive numbers of splinter polygons)? – Vince Nov 21 '16 at 13:09
  • 1
    Please elaborate on what did not seem to work. Was there an error or the result was not as expected? – kttii Nov 21 '16 at 14:21
  • The output is not the one I would.. I would like to reduce the features but their number is always the same – Glori P. Nov 21 '16 at 15:24
  • I'm marking this as a duplicate, but please do check out the referenced question as I think the answer will solve your problem as well. – Get Spatial Nov 21 '16 at 18:26