<div dir="ltr">Hello all,<div><br></div><div style>I have a table with multipolygon geometry in EPSG:3857 (web mercator) that I'm trying to dissolve (grouping by a field) into another table using an aggregate call to ST_Union, but for some reason the SRID isn't carrying over (SRID gets set to zero). I've also tried calling ST_SetSRID on the result but that too results in SRID = 0.</div>
<div style><br></div><div style>I'm fairly new to PostGIS - can anyone point out my mistake?</div><div style><br></div><div style>Here's the query I'm using:</div><div style><br></div><div><div> CREATE TABLE ds1_dissolved AS SELECT code,ST_Union(ST_SnapToGrid(wkb_geometry, 0.0001)) AS wkb_geometry FROM ds1 WHERE ST_IsValid(wkb_geometry) GROUP BY code;</div>
<div><br></div><div style>or, with an additional call to ST_SetSRID:</div><div style><br></div><div style> CREATE TABLE ds1_dissolved AS SELECT code,ST_SetSRID(ST_Union(ST_SnapToGrid(wkb_geometry, 0.0001)), 3857) AS wkb_geometry FROM ds1 WHERE ST_IsValid(wkb_geometry) GROUP BY code;</div>
<div style><br></div><div style>Both methods seem to work except for the SRID being set to zero as reported in geometry_columns:</div><div style><br></div><div style> # SELECT * FROM public.geometry_columns WHERE f_table_name='ds1_dissolved';<br>
</div><div style> </div><div style><div> f_table_catalog | f_table_schema | f_table_name | f_geometry_column | coord_dimension | srid | type</div><div> -----------------+----------------+----------------------------+-------------------+-----------------+------+--------------</div>
<div> dbname | schemaname | ds1_dissolved | wkb_geometry | 2 | 0 | GEOMETRY</div><div style> (1 row)</div><div style><br></div><div style>Describing the original table using \d reports the type of the 'wkb_geometry' field as: geometry(MultiPolygon,3857)</div>
<div style>Describing the dissolved table using \d reports the type of the 'wkb_geometry' field as: geometry</div><div style><br></div><div style>Any help greatly appreciated!</div><div style><br></div><div style>
Thanks,</div><div style>Jason</div></div>
</div></div>