10 Replies Latest reply on Jan 6, 2014 11:55 AM by jbante

# Calculate polygon area from latitude, longitude coordinates.

Hi there,

I'm relatively new to Filemaker. I've written a script to create a KML polygon file based on the work from Otto Muller found here.

https://fmdev.filemaker.com/message/102408#102408

I would like to add the ability to calculate the polygon area (acres or hectares) based on my list of latitude, longitude coordinates that make up the boundary of the polygon. Does anyone have any advice how to do this? Script/ Custom Function?

Any help would be most appreciated.

Thanks,

Dan

• ###### 2. Re: Calculate polygon area from latitude, longitude coordinates.

Thanks for the advice - I have been trying the PolygonArea custom function.  So far it doesn't seem to like my 'negative' longitude values for the xlist.

My coordinates look like this:

Thanks for any information you can provide,

Dan

• ###### 3. Re: Calculate polygon area from latitude, longitude coordinates.

Hypothetically, you should be able to add 180 to all your longitude values without changing how the PolygonArea function works.

Note that the custom function assumes a flat cartesian coordinate space, not the surface of the Earth. It can be a reasonable approximation (the smaller and closer to the equator, the better), but don't confuse it for an exact calculation. More accurate calculations involve more sophisticated math. Consider adapting this example if a spherical approximation would be good enough. It's not perfect, but it's much better than the cartesian approximation. If you really need the most exact result possible, look at porting some of the functionality in Geographiclib. Even if you don't use Geographiclib, you can use this web-based version of some of it to judge the quality of your approximations from other methods.

• ###### 4. Re: Calculate polygon area from latitude, longitude coordinates.

jbante, is it add 180, or just drop the minus sign ( - ) ? [nothing snarky here. I truly don't know which is correct. I've just been treating the negatives as positive]

• ###### 5. Re: Calculate polygon area from latitude, longitude coordinates.

Add 180°. Taking the absolute values of the coordinates (dopping the minus sign) will lead to problems if you run into a polygon that straddles the prime meridian. Either of the more accurate methods I linked to should handle the issue or make it a moot point.

• ###### 6. Re: Calculate polygon area from latitude, longitude coordinates.

Thank you...

• ###### 7. Re: Calculate polygon area from latitude, longitude coordinates.

Thanks jbante,

I will try adding 180 to my longitude values.  My application is only for use within the Province of British Columbia so I'm not concerned about straddling the prime meridian.

Cheers,
Dan

• ###### 8. Re: Calculate polygon area from latitude, longitude coordinates.

At that latitude, I strongly encourage you to try one of the more sophisticated methods I linked to. Using the cartesian approximation will produce areas that are too small by about 41%.

• ###### 9. Re: Calculate polygon area from latitude, longitude coordinates.

Thanks for the tip!  Do you think it would be possible to implement the Polygon Area script from here: http://geographiclib.sourceforge.net/scripts/geod-calc.html  using a filemaker web viewer?

What I have is a filemaker go form that is meant to be used offline on an iPad in the field.  Among other things the hope is for the form to capture polygon area from the iPad GPS coordinates from the user walking the boundary of the polygon.   So far I have the polygon part working with the output being KML.

Dan

• ###### 10. Re: Calculate polygon area from latitude, longitude coordinates.

It could be possible, but it might be simpler to implement this calculation in FileMaker instead.