If you use JavaScript and want to calculate bbox area there, you can do that using @turf functions:
import area from "@turf/area"; import bboxPolygon from "@turf/bbox-polygon"; ... const bbox = [-20, -20, 20, 20]; const result = area(bboxPolygon(bbox))
or you can do that yourself:
const bbox = [-20, -20, 20, 20]; ... const earthRadius = 6371008.8; const [west, south, east, north] = bbox; const result = ( (earthRadius * earthRadius * Math.PI * Math.abs(Math.sin(rad(south)) - Math.sin(rad(north))) * (east - west) ) / 180 ); // rad is: function rad(num) { return (num * Math.PI) / 180; }
Note: if you use @turf/area 6.5.0, they have a hardcoded earthRadius equal to 6378137. Whereas you can also take it from @turf/helpers and it is equal to 6371008.8 there. That might lead to area differences between different methods. They fixed this in v7 (which is alpha at this moment).