[postgis-users] PostGIS 1.3.3 on Windows XP Unstable

Obe, Regina robe.dnd at cityofboston.gov
Mon Aug 18 05:15:04 PDT 2008


I could very well be an idiot or at least as far as using ArcMap is
concerned.  I tested union out in ArcMap - not knowing anything of
course.  I figured I have it installed might as well see the slickness
of ArcGIS with mine own eys. I'm using ArcGIS 9.2 - I've been too lazy
to install ArcGIS 9.3.

First it took me a while to figure out where the Union tool is.  It
wasn't intuitively obvious like it is in OpenJump.

Then finally after fumbling in the help - I saw a button in the help
that says "Open Tool".  attached is what my options look like and what I
had set.

Then I ran it - took about 2.5 secs on my pc and to my shock - it did a
stupid collect which PostGIS can do in 1.5 seconds or less.

How the hell do you get it to do a real union?

By the way Martin - I've got my timings down to 8.5 seconds with the
st99_00 dataset using the  envelop trick - but I'm sure I still have a
lot of inefficiencies I'm missing.



-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Bresnahan, Mike
Sent: Thursday, August 14, 2008 7:45 PM
To: PostGIS Users Discussion
Subject: RE: [postgis-users] PostGIS 1.3.3 on Windows XP Unstable

Hash: SHA256

> FWIW:  The unioning operations currently in PostGIS are very

Do I guess right that PostGIS iterates over each geometry and unions it
with the result of all previous geometries, something like this:

            java.awt.geom.Area area = null;
            for (Geometry geom : geomList) {
                if (area == null) {
                    area = ConvertToArea(geom);
                else {
                    path = area.add(ConvertToArea(geom)); // union

AFAIK, that is what Oracle does and it is quite slow.

> We are working on improving the union operation in PostGIS and
> will have at least a first draft to show in the next release.  Most
> notably
> porting the JTS logic for doing Cascaded Unions to PostGIS.

By Cascaded Unions do you mean a routine that works something like this:

            java.awt.geom.Area subArea = null; 
            int rowCount = 0;
            while (result.next()) {
                JGeometry geom = JGeometry.load(result.getBytes(1));
                java.awt.Shape shape =
                if (shape != null) {
                    if (subArea == null) {
                        subArea = new java.awt.geom.Area(shape);
                    else {
                        subArea.add(new java.awt.geom.Area(shape));
                    if (rowCount % 10 == 0) {
                         if (area == null) {
                            area = subArea;
                        else {
                        subArea = null;

I have found that this is indeed faster that the first approach, but
what I have found that is even faster is to create one large geometry
collection and union it with itself like this:

            java.awt.geom.GeneralPath path = null;
            for (Geometry geom : geomList) {
                if (path == null) {
                    path = ConvertToPath(geom);
                else {
                    path = AppendToPath(path, geom);
            java.awt.geom.Area area = new java.awt.geom.Area(path);
            area.add(area); // self-union

I think the gain here is that you only build the temp data structures
for each polygon once. I'm guessing that this is what ArcMap does.

Version: PGP Universal 2.8.3
Charset: us-ascii

postgis-users mailing list
postgis-users at postgis.refractions.net

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
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arcgisunion.png
Type: image/png
Size: 37960 bytes
Desc: arcgisunion.png
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080818/ec907beb/attachment.png>

More information about the postgis-users mailing list