Geographic Bounding Boxes Explained

A bounding box is four numbers that enclose a place. Simple in principle, but axis order, the antimeridian and the poles cause a surprising number of bugs.

A geographic bounding box (bbox) is the smallest rectangle, in latitude and longitude, that encloses a feature. It is described by four numbers: the minimum and maximum longitude (the west and east edges) and the minimum and maximum latitude (the south and north edges). Every edge is a line of constant longitude or constant latitude, so on a standard web map a bbox is drawn as an upright rectangle.

A bounding box with its four edges and southwest and northeast corners north = max lat south = min lat west min lon east max lon SW NE [west, south, east, north]
The shaded place touches all four edges of its bounding box. The southwest corner holds both minimums and the northeast corner both maximums.

A worked example: Nominatim's bounding box for the Eiffel Tower is west 2.2933119, south 48.8574753, east 2.2956897, north 48.8590453. The height is 0.0015700° of latitude, about 175 m. The width is 0.0023778° of longitude, which at latitude 48.86° (where a degree of longitude spans roughly 73.4 km) is also about 175 m. You can draw, edit and export boxes like this with the bounding box explorer.

Which order are the four numbers in?

There is no single convention, and mixing them up is the most common bbox bug. GeoJSON, defined in RFC 7946, section 5, lists all axes of the southwesterly corner followed by all axes of the northeasterly corner, and positions are always longitude then latitude. A two-dimensional GeoJSON bbox is therefore [west, south, east, north].

Other tools disagree:

SourceOrderEiffel Tower example
GeoJSON bbox (RFC 7946)west, south, east, north[2.29331, 48.85748, 2.29569, 48.85905]
Nominatim boundingboxsouth, north, west, east (as strings)["48.85748", "48.85905", "2.29331", "2.29569"]
Leaflet LatLngBounds[[south, west], [north, east]][[48.85748, 2.29331], [48.85905, 2.29569]]
OpenGeocoder 2012 dumpwest, south, east, northSame as GeoJSON

The Nominatim output documentation describes boundingbox as min latitude, max latitude, min longitude, max longitude, and its JSON examples return each value as a quoted string. Convert explicitly rather than relying on position:

// Nominatim: [south, north, west, east] as strings
const [south, north, west, east] = result.boundingbox.map(Number);
const geojsonBbox = [west, south, east, north];

A quick sanity check catches many swaps: latitudes must lie between −90 and 90, so if your "south" value is 122.1 you are reading a longitude. Values that are all small and close together, as in the Eiffel Tower example, will pass that check, so test with a place in the western or southern hemisphere too. The coordinate converter helps when a box arrives in another format, and our guide to coordinate formats covers the formats themselves.

Boxes that cross the antimeridian

Longitude jumps from +180° to −180° at the antimeridian, which runs through the Pacific. A feature that straddles it, such as Fiji, has a western edge east of 180° and an eastern edge west of it. RFC 7946 section 5.2 handles this with a simple rule: when a box crosses the antimeridian, its east value is less than its west value. The RFC's own Fiji example is [177.0, -20.0, -178.0, -16.0], a box 5° wide. The complementary box [-178.0, -20.0, 177.0, -16.0] describes the other 355° of the globe.

A bounding box from 177 degrees east to 178 degrees west crossing the 180 degree antimeridian antimeridian 180° west = 177 east = −178 16°S 20°S 175°E 180° 175°W
RFC 7946's Fiji example. Because the box crosses 180°, its east value (−178) is smaller than its west value (177).

Not every system follows that rule. At the time of writing, Nominatim's bounding box for Fiji, which also covers its outlying islands, runs from −180 to 180 in longitude: it spans the entire width of the globe rather than wrapping. Any box you receive with a west of −180 and an east of 180 deserves a second look.

Code that assumes west < east breaks in two quiet ways:

  • Centers. Averaging 177 and −178 gives −0.5, a point in the South Atlantic. The correct center longitude is (177 + (−178 + 360)) / 2 = 179.5, which is within the box.
  • Containment. The usual test west <= lon && lon <= east never succeeds when west > east. For a crossing box, the test becomes lon >= west || lon <= east.

Boxes at the poles

A box that contains a pole cannot be bounded by meridians, because every meridian meets there. RFC 7946 section 5.3 says such a box spans all longitudes: [-180.0, minlat, 180.0, 90.0] for the North Pole and [-180.0, -90.0, 180.0, maxlat] for the South Pole. Note that most web maps use Web Mercator, which cannot display latitudes beyond about ±85.05°, so polar boxes are clipped on screen even when the data is correct.

Why bounding boxes are coarse

A box is a cheap approximation, and for many shapes it is a poor one. Chile is the classic case. Nominatim's box for the country runs from about 109.68°W to 66.08°W and from 56.73°S to 17.50°S, because the boundary includes Easter Island (Rapa Nui) far out in the Pacific. The area of a latitude/longitude box on a sphere of radius R is R² × Δλ × (sin φnorth − sin φsouth), with Δλ in radians. Using R = 6,371 km, that box covers about 16.5 million km². Chile's land area is roughly 756,000 km², so the country fills under 5% of its own bounding box.

Even without remote islands, long thin countries and countries that run diagonally, such as Japan, enclose large areas of sea and neighboring territory within their boxes. The practical consequences:

  • "Is this point in the bbox?" is a candidate test, never proof that the point is inside the place.
  • A bbox center can fall outside the feature entirely (often in the ocean for coastal or island countries).
  • Box area is a misleading proxy for the feature's size.

What bounding boxes are good for

Fitting the map view

The most common use is zooming a map to show a result. Mapping libraries provide a "fit bounds" call that picks the zoom and center that fit a box, usually with padding so the feature is not pressed against the edges. This works far better than centering on a point at a fixed zoom, because a city and a building need very different zoom levels. For antimeridian boxes, check whether your library expects east greater than west; you may need to pass the east edge as 182 (−178 + 360) rather than −178.

Spatial pre-filtering

Comparing four numbers is far cheaper than a point-in-polygon test against a detailed boundary. Databases and spatial indexes exploit this by storing a bbox per geometry, finding the few candidates whose boxes overlap the query, and running the exact geometric test only on those. In PostGIS, for example, the && operator compares bounding boxes, and functions such as ST_Intersects use the same index before testing the true shapes. Geocoders use boxes the same way: Nominatim's search accepts a viewbox parameter to prefer, or with bounded=1 restrict, results within a box.

Bounding boxes as WKT and GeoJSON polygons

Many systems do not accept a bare four-number array and need the box as a polygon instead. A polygon ring lists the four corners and repeats the first one to close the ring. In Well-Known Text, coordinates are written as longitude then latitude:

POLYGON((2.29331 48.85748, 2.29569 48.85748, 2.29569 48.85905, 2.29331 48.85905, 2.29331 48.85748))

The GeoJSON equivalent follows RFC 7946's right-hand rule, which makes exterior rings counterclockwise (southwest, southeast, northeast, northwest):

{"type": "Polygon", "coordinates": [[
  [2.29331, 48.85748], [2.29569, 48.85748],
  [2.29569, 48.85905], [2.29331, 48.85905],
  [2.29331, 48.85748]
]]}

For a box that crosses the antimeridian, RFC 7946 section 3.1.9 recommends cutting the geometry in two so that neither part crosses it. The Fiji box becomes a MultiPolygon with one part from 177° to 180° and another from −180° to −178°. The bounding box explorer exports boxes as west,south,east,north, GeoJSON and WKT.

A place as a box: the original OpenGeocoder

Bounding boxes were the whole idea behind the original OpenGeocoder in 2012. Instead of parsing addresses against large datasets, it mapped each search string directly to a bounding box. When a query had no result, visitors could drag a rectangle over the place and save it, and every contribution was placed in the public domain. Its data dump stored each box in the GeoJSON order, west, south, east, north.

The records show both the appeal and the limits of the approach. The entry for "redmond, washington" is a box only about 390 m by 200 m, far smaller than the city itself: a hand-drawn box captures what one contributor had in mind, not an authoritative boundary. You can browse its roughly 1,890 records in the OpenGeocoder 2012 archive, and read more about the project's history and relaunch on the about page.

Key takeaways

  • A bbox is four numbers; GeoJSON orders them west, south, east, north, while Nominatim returns south, north, west, east as strings. Convert explicitly.
  • When a box crosses the antimeridian, east is less than west; centers and containment tests need special handling.
  • Boxes containing a pole span all longitudes, from −180 to 180.
  • Boxes are coarse: Chile fills under 5% of its own box. Use them to fit map views and to pre-filter, then test against real geometry.