# [postgis-users] problem creating and exporting a polygon with holeusing pgsql2shp

Obe, Regina robe.dnd at cityofboston.gov
Wed Mar 12 04:51:33 PDT 2008

```I'm guessing your result may be a Geometrycollection which ESRI shape
has no clue what to do with.

If I understand you correctly, I think you really should be using

So ST_Difference(polygon2, polygon1) - will give you that portion of
polygon2 which does not intersect with polygon1 which would give you a
polygon with polygon1 removed (a doughnut so to speak).

The ST_Symdifference will give you that portion of polygon2 not in
polygon1 + polygon1 not in polygon2 = the holed polygon you want + an
empty geometry collection -> a geometry collection if taken strictly.
I'm not sure if PostGIS will throw out the second part (the empty
collection) - and at anyrate is a waste of processing power to even
compute it.

Hope that helps,
Regina

________________________________

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Ghislain Geniaux
Sent: Wednesday, March 12, 2008 6:29 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] problem creating and exporting a polygon with
holeusing pgsql2shp

Using a postgis table with Two polygons, in which polygon 1 entirely
contained in polygon 2, I've create a new polygon with a hole using :

------
create table matable2 as
select  r.gid, area(symdifference(r.the_geom,i.the_geom)) as
area,(symdifference(r.the_geom,i.the_geom)) as the_geom from matable as
r, matable as i where i.gid=2 and r.gid=1;

ALTER TABLE matable2 ADD PRIMARY KEY (GID);
\q
pgsql2shp -f ext.shp conversion 'select * from matable2'
-----

Area is correct, display of the polygon in QGIS is also correct, but the
export by pgsl2shp produce an empty shapefile.

How to deal with this problem?

------------------------------------------
Geniaux Ghislain

-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended