[postgis-users] typemod on ST_Union() results

Hugues François hugues.francois at irstea.fr
Sun Oct 20 00:10:54 PDT 2013


Hello,

A multipolygon can not be single polygon but you can declare a polygon to be a multi one with a single element... It is not trivial, but it is !

So, you should try st_multi(st_union())::geometry(multipolygon::srid)

HTH

Hugues


-------- Message d'origine--------
De: postgis-users-bounces at lists.osgeo.org de la part de maplabs at light42.com
Date: dim. 20/10/2013 08:19
À: postgis-users at lists.osgeo.org
Objet : [postgis-users] typemod on ST_Union() results
 
Hi All -

  I have a process where I split a large number of geometries by a second set of (smaller) geometries, then recombine them using a GROUP BY gid.  Both source set and splitter set have the same SRID, and the results, and the combined results, therefore have an SRID. 

  But in the age of typemod, geometry_columns sees a big zero SRID. ugh  Using a cast inline has been suggested, but in this case, the result of the ST_Union()  can be either Polygon or Multipolygon.   As far as I know, the typemod has to know specifically which one.. 
(actually the result should be a single polygon each time but I havent enforced it yet)

e.g. 

-- results in geometry_column SRID 0

create table dbg_z0_avgfs_blue as 

  select  

    p.gid,  sum( p.avg_family_size_estimate * st_area(p.geom_purple) / 22500.0  ) as avg_family_size_estimate,  

    st_union( p.geom_purple ) as geom

from   dbg_z0_avgfs_purple p 

GROUP BY  p.gid;

-- no no

create table dbg_z0_avgfs_blue as  

  select     p.gid,  sum( p.avg_family_size_estimate * st_area(p.geom_purple) / 22500.0  ) as avg_family_size_estimate,    

  st_union( p.geom_purple )::geometry(Multipolygon,3310) as geom  --< FAIL, sometimes its a Polygon

from   dbg_z0_avgfs_purple p

GROUP BY  p.gid;

--

  What to do?  input welcome

--

Brian M Hamlin
OSGeo California Chapter
blog.light42.com

_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3622 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20131020/6d522826/attachment.bin>


More information about the postgis-users mailing list