# Calculating bounding box size?

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
``````
• Welcome to SE.GIS forum . In which software you want to calculate the a bounding box? – Sunil Apr 25 '13 at 6:03
• 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. – whuber Apr 25 '13 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. – Chris Apr 25 '13 at 14:43
• is the data in a spacial format or just in strings? – dassouki Apr 25 '13 at 14:46

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 : `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: Where the area can be calculated with the following formula : where : and l2>l1

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

Thus the formula for the bbox area equals with: .

• 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. – whuber Jul 25 '13 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)`? – nickves Jul 25 '13 at 16:07
• (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. – whuber Jul 25 '13 at 18:11
• Shouldn't alpha equal the difference of the two longitudes, not latitudes? – user49318 Mar 20 '15 at 23:00

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;`