Issue with units when using Turf.js to calculate area

1.1k Views Asked by At

I know Turf.js was created for geospatial analysis of georeferenced data, but I'm wondering if I can use it to analyse features in a cartesian space.

For example, I need to calculate the area of a very simple rectangle, as follows:

turf.area(
  turf.polygon([ [[0,1], [0,0], [1,0], [1,1], [0,1]] ])
)

The result I get from the above calculation is 12391399902.071104, which I understand are square meters. It is also clear that Turf.js is reading [0,1], [0,0], [1,0], [1,1], [0,1] as WGS84 coordinates and what I am looking for is a way to tell Turf.js that these are not geographic coordinates but linear measures in cartesian space.

I know from the specs (https://www.rfc-editor.org/rfc/rfc7946#page-12) that GeoJSON works only with WGS84 and what I'm looking for is probably an improper use of Turf.js itself.

Finally, my question: is there a way in Turf.js of measuring the area of a rectangle with coordinates [0,1], [0,0], [1,0], [1,1], [0,1] in meters (or whatever linear unit) and obtaining 1 m2 (or whatever square linear unit)?

0

There are 0 best solutions below