[postgis-users] masking out part of a MULTILINESTRING

strk at refractions.net strk at refractions.net
Thu Apr 21 07:18:48 PDT 2005


On Thu, Apr 21, 2005 at 10:05:34AM -0400, Purvis, Charlton wrote:
> What a difference difference makes.  Thanks for the help, strk.  But I've
> got a related question now.  Hope I haven't worn out my welcome.
> 
> The difference(the_geom,***) works beautifully when done as part of the DATA
> clause in a .map, but I'm ready to nuke the data directly in the table so
> that I won't have to mask out the unwanted area every time.
> 
> However, when I do that, I end up w/ a total of 3 different geometries:
> 
> etopo2_bathy=# select
> distinct(GeometryType(difference(the_geom,GeometryFromText('BOX3D(-87 24,-79
> 31)'::box3d,-1)))) from etopo2_contours;

First of all stop using GeometryFromText(box3d, -1), which is illegal
(won't work on newer postgis). Just use 'BOX3D(..)'::box3d and rely
on BOX3D::GEOMETRY cast to make it a geometry, and use SetSRID() if
you need a SRID != from -1.

> 
>     geometrytype    
> --------------------
>  GEOMETRYCOLLECTION
>  LINESTRING
>  MULTILINESTRING
> 
> My original table has MULTILINESTRINGs and are bathymetry contours.  Of
> course, when I try to do an update, I get constraint problems on the
> geometry type.  I'm happy to drop the constraint if that's what I need to
> do.  And masking doesn't seem to do the trick, either.  I would have thought
> that a GEOMETRYCOLLECTION geometry type could handle it all, ach no.
> 
> Any ideas?

Teoretically specifying GEOMETRY to the AddGeometryColumn should accept
all types of GEOMETRY, but I'm not sure it still works.
Feel free to drop your constraint, but beware that software relying on
geometry_columns will be disappointed...

Anyway, I belive the GEOMETRYCOLLECTION is just an EMPTY geometry, which
you could filter away setting to NULL with a CASE specification (yes,
the constraint should deal with EMPTY geoms instead but doesn't).
The LINESTRING can be transformed to a MULTILINESTRIN using the multi()
function.

Have fun!

--strk;


> 
> Thanks.
> 
> ________________________________________
> From: Purvis, Charlton [mailto:cpurvis at asg.sc.edu] 
> Sent: Wednesday, April 20, 2005 1:02 PM
> To: 'PostGIS Users Discussion'
> Subject: RE: [postgis-users] masking out part of a MULTILINESTRING
> 
> > This should be difference(geom, box); 
> > --strk; 
> Genius!  Works like a charm.  Thanks. 

> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list