10

What formula could I use to calculate the size in Kilometres of a bounding box based on a given South-West latitude/longitude and a North-East latitude/longitude points?

The bounding box format is defined as:

bounds = sw_latitude, sw_longitude, ne_latitude, ne_longitude 
4
  • 1
    Welcome to SE.GIS forum . In which software you want to calculate the a bounding box? Commented Apr 25, 2013 at 6:03
  • 2
    Do you want the extent in geographic coordinates, as suggested by your use of latitude and longitude, or in projected coordinates, as indicated by your request for size in kilometers? The two boxes usually have different sizes and different shapes. If you want the former, note that it does not have a single "size": its sides will be geodesic and of equal length, but its top and bottom will be circles of latitude and usually of different lengths, giving three "sizes" altogether. There is no such problem in the latter case. Commented Apr 25, 2013 at 13:51
  • I am doing a bounding box search on a MySQL database and I would like to check the area size of the given SouthWest and NorthEast points is not too large. Commented Apr 25, 2013 at 14:43
  • 2
    is the data in a spacial format or just in strings? Commented Apr 25, 2013 at 14:46

3 Answers 3

13

Generally to calculate the area of a bbox in a projected coordinate system since it's a (big) rectangle you can use the area formula :

enter image description here

area = (sw_longitude - ne_longitude) * (sw_latitude - ne_latitude)

Depending now on your spatial location (ie you're in a projected crs) the above formula will give you square mapunits (km^2, m^2 whatever).

In case you're in a sphere, like earth, you can use the sperical zone approach:

enter image description here

Where the area can be calculated with the following formula :

enter image description here

where :

enter image description here and l2>l1

And since you want a sector of the zone, you'll need to multiply the above with enter image description here where α = lat2 - lat1

Thus the formula for the bbox area equals with:

enter image description here

.

4
  • 5
    Your proposal fails to calculate the area correctly, making huge errors for regions away from the Equator. A spherical approximation will work well enough. Let the two longitudes be l1 < l2, the latitudes be f1 < f2 (all in degrees), and let R = 6,371.0072 kilometers be the earth's authalic radius. The BB area equals R^2 * (cos(f2)-cos(f1)) * (l2-l1) / 180 square kilometers. For comparing areas you could drop the multiplicative constant R^2/180, leaving a formula almost as simple as yours--but much more accurate. Commented Jul 25, 2013 at 14:18
  • Yes you are correct, once again :) I'll update the answer accordingly. The simple area approach won't work in a projected CRS though? And shouldn't be a pi in the numerator? Area_sphere_zone = 2*π*R*h -> Area_sphere_zone_arc = 2 * π * R^2 * (cos()-cos()) * (α/360)? Commented Jul 25, 2013 at 16:07
  • 1
    (1) In a projected CRS the geographic bounding box will be a curvilinear shape and so its area is not easily found. (2) Yes, a factor of Pi belongs there: where in my comment I inserted 1/180 I should have used Pi/180 to convert from degrees to radians. Thanks for catching that. Also, "cos" should be "sin" (again my mistake: you would use "cos" only with colatitudes, which is not the geographic convention). As a double-check, the formula will give R^2 * Pi * (sin(90) - sin(-90)) * (180 - (-180)) / 180 = 4 * Pi * R^2 for the sphere's surface area, which is correct. Commented Jul 25, 2013 at 18:11
  • 1
    Shouldn't alpha equal the difference of the two longitudes, not latitudes? Commented Mar 20, 2015 at 23:00
1

Based on the answer provided by @nickves and @whuber to calculate area based on bounding box coordinates in MySQL you could use:
SELECT (POW(6371,2) * PI() * ABS(SIN(RADIANS(sw_latitude)) - SIN(RADIANS(se_latitude))) * ABS(ne_longitude - (ne_longitude)) / 180) as area

And to calculate area from bounding box coordinates in php:
pow(6371,2) * pi() * abs(sin(deg2rad($sw_latitude)) - sin(deg2rad($se_latitude))) * abs($ne_longitude - ($ne_longitude)) / 180;

1

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).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.