[postgis-users] Area calculation
David TECHER
davidtecher at yahoo.fr
Tue Jan 27 10:27:03 PST 2004
Hi Dirk
Daniel is right if your geometries are disjoined
but if you use multipolygon joined with hole here is
an example
Suppose that I have this multipolygon= 2 polygon with
holes
MULTIPOLYGON ((
(140 220, 160 140, 200 140, 240 320, 140 300, 140
220),
(160 260, 180 280, 200 260, 180 220, 160 240, 160
240, 160 260),
(160 200, 180 200, 180 180, 180 160, 160 180, 160
180, 160 200)),
((400 300, 460 260, 420 200, 360 200, 340 260, 340
300, 360 340, 400 300),
(380 280, 360 260, 380 220, 420 240, 420 240, 380
280)))
You have to know the number of geometries yoy have
Use numgeometries:
select numgeometries(the_geom) from <yourtable>
Then
If you want to know the aread of the first polygon
that have 2 holes, use area2d and geometryn:
select area2d(geometryn(the_geom,N)) from <yourtable>
Here N=1 is the number of the polygon . Then find the
surface for N=2
Then add all the surfaces you find
I attached an image and a SQL file with my mail for
this example
Here poly 2 and poly 3 are the all of the first
polygone (poly 1) and poly 5 is the hole of the second
polygon (poly 4)
here is what it give me if I do
select nomcouche,area2d(the_geom) from table where
name not like '%all%'
nomcouche | area2d
-----------+--------
poly 1 | 12600
poly 2 | 1400
poly 3 | 600
poly 4 | 10200
poly 5 | 1800
I find with ...area2d(geometryn(the_geom)...:
aread of (poly 1 - (poly 2 + poly 3)) = 10600
aread of (poly 4 - (poly 2 + poly 3)) = 8400
Regards
David
_________________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.jpg
Type: image/pjpeg
Size: 14798 bytes
Desc: example.jpg
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20040127/bb22bcaf/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tempo.sql
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20040127/bb22bcaf/attachment.ksh>
More information about the postgis-users
mailing list