Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript
https://turfjs.org/
MIT License
9.22k stars 935 forks source link

area #6

Closed morganherlocker closed 9 years ago

morganherlocker commented 10 years ago

Returns the area of a polygon in a specified unit.

g.area(poly, 'miles', function(err, area){
  console.log(area)
})
morganherlocker commented 10 years ago

algorithm:

  1. break multipolys into polygons
  2. run seidel on all polygons and append resulting triangles to an array
  3. calculate area of each triangle area = 0.5 * base * height and add the result to a running area sum
tmcw commented 10 years ago

Is this faster than yer basic geodesic area? Seems siedel is O(nlog*n) and the traditional method is O(n)

morganherlocker commented 10 years ago

@tmcw :+1: cool, was not aware of that repo. Should be faster and more accurate than my proposal, so I might just wrap it with turf conventions.

tmcw commented 9 years ago

https://github.com/Turfjs/turf-area

tmcw commented 9 years ago

turf-area is documented, landed, and in package.json.