[postgis-users] query explanation

Brent Wood pcreso at pcreso.com
Sat Apr 22 12:17:25 PDT 2006



--- Frances Collier <fcollier at preparedresponse.com> wrote:

> Hello,
> 
> I am trying to figure out how to write a query that will give me a specific
> area that is the union of a buffer and an intersect result. I haven't been
> able to find anything to give me a hint. Is there anything written that
> gives examples of queries in postgis other than the manual?

Nothing specific that I'm aware of, but area calculation is complex. PostGIS
has the function area2d in addition to the OGC area function, both of which
AFAIK, will return the cartesian area in map units. I'm not sure of the
difference between these, but I'd guess there was a good reason for
implementing the area2d one :-)

To derive a reasonably accurate area, the data needs to be in a suitable
(equal-area) projection. The buffer function may also need to be reprojected to
generate the polygon you require, depending on the data projection and distance
units.

One approach which could work is along the lines of:

select area2d(buffer(transform(<geometry>, <SRID>), <buffer-dist>)) 
       + area2d(transform(intersection(<geometry>, <geometry>))) as geom_area
from <table> .....;

It may get more complex, with more transforms (depending on your data), as you
may require reprojections within your buffer & intersection functions, and your
data may be from different tables...

HTH,

  Brent Wood 



More information about the postgis-users mailing list