Bounding box finder

Draw a box on the map, search a place or paste a bounding box you already have, then copy its coordinates in the order your library expects. Free, no account needed.

Everything you draw stays in your browser. A place search is sent to OpenStreetMap’s Nominatim.

Your bounding box

No box yet. Draw one, use the map view, search a place or paste one.

Edit the numbers

West greater than east crosses the 180° meridian.

What to do next

Find your own places inside a box through the Spatibase API. Create a free project and ask its Content Delivery API for bbox=minLng,minLat,maxLng,maxLat: the Spatibase API row above is that query for this box.

Create a free project
In short

A free bounding box finder that runs in your browser

The Spatibase bounding box finder gets the coordinates of a rectangle on the map, in your web browser. Draw the box, use the current map view, search a place or paste a bbox in any common format, then copy it as minLng,minLat,maxLng,maxLat, a GeoJSON polygon, WKT, Leaflet or MapLibre bounds, an Overpass bbox, an OpenLayers extent in EPSG:4326 or EPSG:3857, an ogr2ogr -spat argument or a Spatibase API query. It handles boxes that cross the 180° meridian and is free with no account. The box stays in your browser; a place search is sent to OpenStreetMap’s Nominatim.

It answers the question behind most bbox searches, “which order?”:

  • Four numbers, several orders. GeoJSON and most web APIs write west, south, east, north; Leaflet, Overpass and Google Maps start with the latitude.
  • Paste to check. Paste a box from your code and see where it lands: on another continent means two values traded places.
  • A Copy button per format. Choose 2 to 7 decimals (6 by default, about 11 cm), and every output follows.
How to

How to get the bounding box of an area

Make the box, check it on the map, copy the format you need.

  1. Press Draw a box and drag across the map; on a phone, tap two opposite corners. No area in mind? Open the sample: central Barcelona.
  2. Or press Use the map view, or search a place to get the box OpenStreetMap stores for it.
  3. Drag the corners or edges until the box covers what you need.
  4. Have a bbox already? Paste it in, in any common order, WKT or GeoJSON, to see where it lands.
  5. Set the decimals and press Copy next to the format your code uses.
Formats

Which order is a bounding box in?

There is no single order. Most formats write west, south, east, north, which is longitude first; a few put latitude first, and one uses an order of its own.

The ones you’ll meet most, and the order each expects:

  • GeoJSON `bbox` member: [west, south, east, north], as RFC 7946 sets out. The same order in Turf’s bbox(), Shapely’s bounds, OpenLayers extents, PostGIS ST_MakeEnvelope and the Spatibase bbox= parameter.
  • MapLibre and Mapbox GL `fitBounds`: [[west, south], [east, north]], longitude first, or the same four numbers flat.
  • Leaflet `fitBounds`: [[south, west], [north, east]]: latitude first, like everything in Leaflet.
  • Google Maps `LatLngBounds`: the south-west corner, then the north-east one, each as { lat, lng }.
  • Overpass QL: (south, west, north, east), latitude first.
  • Nominatim `boundingbox`: [south, north, west, east], as strings: both latitudes, then both longitudes.
  • WKT and `ogr2ogr -spat`: x before y, so longitude before latitude: POLYGON((west south, …)) and -spat west south east north.
  • WMS 1.3.0 with EPSG:4326: latitude first, while WMS 1.1.1 and CRS:84 use longitude first, the classic cause of a sideways map.

Telling a pasted box apart. A latitude lies between −90 and 90, so a larger value must be a longitude. When all four values fit both readings, the finder reads longitude first and says so.

Across the 180° meridian, west is greater than east (Fiji: 177 to −178). GeoJSON allows that, many libraries don’t, so each output notes how it handles one.

For developers

Get a bounding box in code

Turf’s bbox function measures any GeoJSON, map libraries zoom to the result, and the Spatibase Content Delivery API filters your own places by it.

import * as turf from '@turf/turf'

const box = turf.bbox(geojson) // [west, south, east, north] of every coordinate
geojson.bbox = box // GeoJSON can carry it as a "bbox" member

// MapLibre GL and Mapbox GL: longitude first, as two corners
map.fitBounds([[box[0], box[1]], [box[2], box[3]]], { padding: 40 })

// Leaflet: latitude first
leafletMap.fitBounds([[box[1], box[0]], [box[3], box[2]]])

// your published places inside the box (Spatibase Content Delivery API)
const url = `https://api.spatibase.com/delivery/v1/projects/${PROJECT_ID}/entries?bbox=${box.join(',')}`
const { data } = await (await fetch(url)).json()

Turf’s bbox ignores the 180° meridian: points on both sides give a box around the rest of the world. d3-geo’s geoBounds handles it and returns a west greater than the east.

The Delivery API takes bbox=minLng,minLat,maxLng,maxLat with each minimum at most its maximum, so a box across the 180° meridian takes two requests. A public project needs no key.

With GDAL, ogrinfo -so -al in.gpkg prints each layer’s extent; ogr2ogr -spat keeps what touches a box given in the layer’s own coordinates.

FAQ

Questions about bounding boxes

What order are bounding box coordinates in?

Usually west, south, east, north (minLng, minLat, maxLng, maxLat), as in GeoJSON, Turf and most web APIs. Leaflet, Overpass and Google Maps put latitude first, and Nominatim gives south, north, west, east. Paste yours above to see which reading lands where you expect.

Why is my bounding box upside down or in the wrong place?

Two values traded places. With latitude and longitude swapped, a box around Barcelona lands in East Africa; with south and north swapped, some libraries flip it back and others refuse it; with west and east swapped, the box runs the long way round the world.

What is EPSG:3857, and why is that bbox in metres?

EPSG:3857 is Web Mercator, the projection of almost every web map. Its coordinates are metres from where the equator meets the Greenwich meridian, up to about 20,037,508 each way, and it stops at 85.05° north and south. OpenLayers uses it by default; most other tools want degrees (EPSG:4326).

How do I get the bounding box of a city or country?

Search for it: OpenStreetMap’s Nominatim stores a box for every place it knows. A country with territories far away, such as France, can get a box around most of the world; draw a tighter one by hand.

How do I write a bounding box that crosses the 180° meridian?

Keep west greater than east: Fiji’s box runs from 177 to −178. GeoJSON allows exactly that. For a library that doesn’t, add 360 to the east value (182) or split the box in two, one on each side of the line.

How many decimals does a bounding box need?

Four decimals are about 11 m, plenty for a city or a map view; six are about 11 cm. More only make the numbers longer.

Want to filter your own places by a box? Read how to import places into Spatibase, then the Delivery API’s bbox filter.

Talk to us

Not sure it’s a fit? Let’s find out

Tell us about your use case and what you need, from data model to security and deployment. In 30 minutes we’ll look at it together and tell you honestly if we can help.

Or write to hello@spatibase.com.