[postgis-users] Using ST_intersection on Polygons returns multiple types

2012-03-07 Thread Rebecca Clarke
Hi there

I have 2000 polygons in table A and I want to show only the polygons that
intersect with the bounding box specified in table B  . So I do this:

SELECT the_geom
FROM  A
WHERE st_intersects(the_geom, (select the_geom from B))
AND ST_GeometryType(the_geom) = 'ST_Polygon'

This query returns all the intersecting polygons. When I run
st_geometrytype they are all St_Polygon.

Some of the polygons are large and exceed the boxes boundary so I use this
query to trim them:

SELECT st_intersection(the_geom, (select the_geom from B)) as the_geom
FROM  A
WHERE st_intersects(the_geom, (select the_geom from B))
AND ST_GeometryType(the_geom) = 'ST_Polygon'


The problem I'm having is that when I use the st_intersection, instead of
returning just St_Polygon's, it's returning other types as well:

ST_LineString
ST_MultiLineString
ST_MultiPolygon
ST_Polygon

I need to output the results to a SHP file and this is preventing me from
doing so seeing there is more than one Geom Type.

Any ideas how I can keep the results of the st_intersection as just
St_Polygons? Am I doing something wrong?

Regards

Rebecca
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Using ST_intersection on Polygons returns multiple types

2012-03-07 Thread Paul Ramsey
ST_Intersection is perhaps a bit more complete than most users would
like. If two polygons share a boundary what is their intersection? Not
a polygon, but that linear, shared boundary: a line. Similar for
touching at a point.

Anyhow, probably a cleaner approach would be an extra optional
argument to ST_Intersection allowing users to specify the
dimensionally of the return, but in the meanwhile you can go to
ST_CollectionExtract and use that to pull out just the polygons.

P.

On Wed, Mar 7, 2012 at 9:58 AM, Rebecca Clarke rebe...@clarke.net.nz wrote:
 Hi there

 I have 2000 polygons in table A and I want to show only the polygons that
 intersect with the bounding box specified in table B  . So I do this:

     SELECT the_geom
 FROM  A
 WHERE st_intersects(the_geom, (select the_geom from B))
 AND ST_GeometryType(the_geom) = 'ST_Polygon'

 This query returns all the intersecting polygons. When I run st_geometrytype
 they are all St_Polygon.

 Some of the polygons are large and exceed the boxes boundary so I use this
 query to trim them:

     SELECT st_intersection(the_geom, (select the_geom from B)) as the_geom
 FROM  A
 WHERE st_intersects(the_geom, (select the_geom from B))
 AND ST_GeometryType(the_geom) = 'ST_Polygon'


 The problem I'm having is that when I use the st_intersection, instead of
 returning just St_Polygon's, it's returning other types as well:

 ST_LineString
 ST_MultiLineString
 ST_MultiPolygon
 ST_Polygon

 I need to output the results to a SHP file and this is preventing me from
 doing so seeing there is more than one Geom Type.

 Any ideas how I can keep the results of the st_intersection as just
 St_Polygons? Am I doing something wrong?

 Regards

 Rebecca





 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users