Brian Dunning's FileMaker Custom Functions

calcAreaFromLatLngPolygon ( polygonJson ; outputUnit )

calculate area in different units of a polygon based on a lat/lng coordinate array (json)

  Average rating: 4.0 (1 vote) Log in to vote

Alexander Baier   Alexander Baier - Show more from this author
datamat Software Development
http://fm-tutorial.de

Share on Facebook Share on Twitter

  Sample input:
calcAreaFromLatLngPolygon( "[{\"lat\":52.5220503095481,\"lng\":13.3857699952148},{\"lat\":52.5230947811845,\"lng\":13.3692905030273},{\"lat\":52.5120221182497,\"lng\":13.3644839844726},{\"lat\":52.506589225608,\"lng\":13.3871432862305},{\"lat\":52.5151561739,\"lng\":13.377873571875},{\"lat\":52.5178721746602,\"lng\":13.3895465455078}]" ; "" )
  Sample output:
{
"acre" : 426.560354699059,
"feet" : 18581782.9278478,
"hectar" : 172.628975546709,
"inch" : 2675749120.97399,
"kilometre" : 1.72628975546709,
"metre" : 1726289.75546709,
"yard" : 1932754.01022096
}

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Calculates the area of an n-sided polygon based on Lat and Lng.

Create a JSON array [{"lat": xxx, "lng": yyyy}]

Returns the area of the polygon in various units of measure as the result. Set "meter" as "outputUnit" to get the result in meters. If the value is empty, a JSON with all units is returned.

 

Comments

Nick Gaunt   Nick Gaunt
Aug 21, 2021
This is a useful function but the commas in "yard" and "feet" need to be changed to periods before it will compile.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: