I use QGIS to process polygons with a source CRS of EPSG:3006. I then use these in Mapbox for which I need to use Turf to calculate the area. When using turf.area to calculate the area of a polygon, it gives an error in the range of 5-100+ square meters depending on how large the polygon is.

I don't think a change in projection should make this much of a difference, since reimporting the GeoJSON into QGIS shows the correct area.

here is an example:


Turf gives this multipolygon an area of 4012.8884841975305 square meters.

Importing this exact GeoJSON back into QGIS and calculating the area from there gives around 4030 square meters, which is exactly what the original projection of the polygon gave. For reference, the QGIS measurement I'm looking at is the ellipsoidal area calculated using GRS80.

I couldn't find anything about this issue when googling, but suspect it must have something to do with turf's area algorithm.

EDIT: I was able to get this working correctly using the answer from Francisco, with geographiclib-geodesic.

Here is the code I made for wrapping the functionality of that library for use with GeoJSON features and featurecollections (using turf's method and some questionable Typescript)

import { geomReduce } from "@turf/meta";
import { Coord, Feature, FeatureCollection, MultiPolygon, Polygon } from "@turf/turf";

const geodesic = require('geographiclib-geodesic');
const geod = geodesic.Geodesic.WGS84;

export default function area(geojson: FeatureCollection<MultiPolygon|Polygon> | Feature<MultiPolygon|Polygon>): number {
    return geomReduce(geojson, (value, geom) => value + calculateArea(geom), 0);

function calculateArea(geom: MultiPolygon|Polygon): number {
    switch (geom.type) {
        case 'Polygon':
            return  polygonArea(geom.coordinates);
        case 'MultiPolygon':
            return geom.coordinates.reduce((value, coords) => value + polygonArea(coords), 0);
            return 0;

function polygonArea(coords: Coord[][]): number {
    return coords.reduce((value, coord) => value + computeRing(coord), 0);

function computeRing (coordinates: Coord[]): number {
    const poly = geod.Polygon(false);
    coordinates.forEach((coord) => {
        poly.AddPoint(coord[1], coord[0]); // NOTE - lat, lng order

    let computed = poly.Compute(false, true); 
    return Math.abs(computed.area);

2 Answers 2


Probably you are affected by this bug. turf.area uses an earth radius value different that other software like PostGIS.

There is a fix in the repo but seems not to be available in the last published version of turf, v6.5.0. It seems that will be realeased with version 7.0.0.

My suggestion is build your own version of turf from GitHub repo, or make a small hack on your own copy.

Just search for const RADIUS = 6378137; and replace it with const RADIUS = 6371008.8. It is in packages/turf-area/index.ts.

But there are more tickets open in turf about troubles with how area is calculated. This one has a good explanations about the problem. The resume is that Turf's area algorithm is based on this paper, "that work directly on a sphere".

In the same ticket a reporter suggests the use of geographiclib-js that use ellipsoidal calculations and provides a sample of code (that I copy&paste here), and assumes that you have the library loaded.

// similar to turf, summing up rings (i.e. multipolygons)
// this may not be necessary if the geographic polygon can support multipolygons
function polygonArea(coords: number[][][][]) {
  let total = 0;
  if (coords && coords.length > 0) {
    for (let i = 0; i < coords.length; i++) {
      const area = geographicLibArea(coords[i][0]);
      total += area;
  return total;

const geographicLibArea = (coordinates: Array<Coord>) => {
  // the geodesic format of my lat, lng coordinates
  // you can specify your own if you have the appropriate constants
  const geod = GeographicLib.Geodesic.WGS84;

  // build polygon in geographic
  let poly = geod.Polygon(false);
  for (let i = 0; i < coordinates.length; ++i) {
    poly.AddPoint(coordinates[i][1], coordinates[i][0]);

  poly = poly.Compute(false, true);

  return Math.abs(poly.area.toFixed(0));

So, Turf does not use ellipsoidal calculations for the area. If that is needed another library must be used.

  • Hmm so I tried this but it still seems to give an incorrect (or at least different) answer from that of QGIS. After changing the radius, I get 4003.92 for the example Multipolygon in my question.
    – Axekan
    Aug 28, 2022 at 9:19
  • @Axekan I updated the post after a quick research in turf issues. Aug 28, 2022 at 11:17
  • Thank you, I was able to get this to work.
    – Axekan
    Aug 28, 2022 at 13:32



I got exact value matching with QGIS Area

  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Dec 29, 2023 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.