This project has moved and is read-only. For the latest updates, please go here.

Calculate area of an irregular polygon

Topics: Algorithms, SharpMap Project, Web Controls
Aug 22, 2008 at 12:20 PM
Greetings all,

I just created a drawing tool for my mapping app. I create a polygon and would like to calculate the are of the polygon.

Would anyone be able to advice me how to calculate the area of the polygon in sq meters if i know:

x,y - image coordinates of each edge of the polygon

lat,lon of each edge of the polygon.

Any advice?

Aug 23, 2008 at 7:06 AM
Hi Dan,

If you know the screen coordinates, you can convert them to world coordinates with the ImageToWorld method.  From there, use the function I gave you before to convert lat/lon to UTM.  Then use a function which you can easily find on the web to calculate the area of the polygon.  There's usually some requirements on that the x/y pairs must be in order and go in a clockwise direction as I recall.  You might find it easier to create a TIN of the polygon first which is to break the polygon down into triangles.  I saw a library that does that somewhere on codeproject I think. 

A word of warning...accuracy for converting from screen to world coordinates is very dependant on zoom level.  Obviously the closer in you zoom, the more accurate the conversion becomes.

- Dirk
Aug 24, 2008 at 7:06 AM
Greetings Dirk,

Thank you for the response.

I found a way to convert the lat/lon to UTM. Then i also got a formula to calculate the area of a polygon for know vertices. The vertices are in order and they are clockwise.

But would using the UTM give me the area in square meters?

I was just doing some testing and the result i get back from my area function is not correct.

The UTM values i get back are correct and also the Area function is correct. Are there any conversion i need to do?

Aug 24, 2008 at 10:36 AM
Greetings mate,

I found a solution to my problem finaly.

What i did was this:

1. I got all the x and ys...From that i got all the lat/lons.

2. I built a polygon from that.

3. Triangulated the polygon ...i,e dissolved the polygon on triangles.

4. By using the lat/lon i can find the sides of the triangles.

5. Use the Heron formula for area of triangle

6. Add all the areas

Dirk thank you for your responses.

Much apreciated.

Sep 9, 2008 at 9:39 PM
why we don't use Area method of  Geometries?
Is it possible to convert them to sq meters?
If not how can we calculated intersected area (as sq meters) of a polygon and a circle?