[postgis-users] ST_Union - Resulting SRID set to 0

Jason Greenlaw - NOAA Affiliate jason.greenlaw at noaa.gov
Thu Jun 27 07:48:47 PDT 2013


Hello all,

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.

I'm fairly new to PostGIS - can anyone point out my mistake?

Here's the query I'm using:

    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;

or, with an additional call to ST_SetSRID:

    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;

Both methods seem to work except for the SRID being set to zero as reported
in geometry_columns:

    # SELECT * FROM public.geometry_columns WHERE
f_table_name='ds1_dissolved';

     f_table_catalog | f_table_schema |        f_table_name        |
f_geometry_column | coord_dimension | srid |     type

-----------------+----------------+----------------------------+-------------------+-----------------+------+--------------
     dbname          | schemaname     | ds1_dissolved | wkb_geometry      |
              2 |    0 | GEOMETRY
    (1 row)

Describing the original table using \d reports the type of the
'wkb_geometry' field as:  geometry(MultiPolygon,3857)
Describing the dissolved table using \d reports the type of the
'wkb_geometry' field as: geometry

Any help greatly appreciated!

Thanks,
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130627/17e39466/attachment.html>


More information about the postgis-users mailing list