ForHosting KIT · Travel & geography

Bounding box union

Two boxes, one from latitude 40.7 to 40.8 and one from 40.75 to 40.9, merge into a single box from 40.7 to 40.9, with longitudes from −74.1 to −73.85. You also get its width, height, area and centre point. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Min lat a
40.7
Max lat a
40.8
Min lon a
-74.1
Max lon a
-73.9
Min lat b
40.75
Max lat b
40.9
You get
Min lat
40.7
Max lat
40.9
Min lon
-74.1
Max lon
-73.85

A bounding box union calculator takes two geographic rectangles defined by minimum and maximum latitude and longitude and returns the single smallest axis-aligned rectangle that fully contains both. Map pipelines often collect separate envelopes—one per layer, cluster, or download tile—and need one combined viewport, query window, or export extent without inventing a heavier geometry library.

What a bounding-box union is and when you need one

An axis-aligned geographic bounding box is the rectangle defined by a southern latitude, a northern latitude, a western longitude, and an eastern longitude. When you already have two such rectangles—from independent feature queries, tile caches, mobile offline packs, or sibling microservices—you often need the single envelope that covers every corner of both without computing a full multipolygon dissolve.

The classic union for axis-aligned boxes is component-wise extremes: the union southern edge is the smaller of the two southern edges; the northern edge is the larger of the two northern edges; the western edge is the smaller of the two western longitudes; the eastern edge is the larger of the two eastern longitudes. That construction is the smallest axis-aligned rectangle that still contains both inputs, measured in the same lat/lon coordinate system.

Teachers, GIS students, and backend engineers care that inverted ranges (min greater than max) are hard errors: silently swapping corners would hide client bugs and produce envelopes that do not match the intended layers. Nested cases are handled naturally by the same min/max rule: if box A sits entirely inside box B, the union equals B; if the boxes are identical, the union equals either. Disjoint boxes still produce a valid envelope that covers the gap between them—useful for map camera framing even when the layers do not overlap.

This landing is for people who already have two bboxes and need their combined extent, not for people who only have a center point and a radius (use a point-radius bounding box tool first) or who need geodesic buffers on an ellipsoid.

Merge layer and query envelopes for map viewports

Combine two independent feature-layer bounding boxes into one camera or tile-request extent that covers every returned geometry.

SQL spatial prefilters across microservices

Union service-A and service-B result envelopes into a single BETWEEN window before a heavier join or distance refinement.

Why is min greater than max rejected?

An inverted range is almost always a client bug.

Does this handle the antimeridian?

The tool applies pure min/max and does not invent a dateline-crossing multipolygon. Prepare unwrapped ranges client-side if you need that case.

Is the bounding box union calculator free?

The browser tool is free and runs locally.

What happens if one box sits entirely inside the other?

The union is simply the larger box, because its edges are already the extremes. If the two boxes are identical, the union equals either of them. The same min and max rule covers both cases.

Can I merge two boxes that do not touch?

Yes. Disjoint boxes still produce a valid envelope that also covers the gap between them. That is handy for framing a map view around two layers that do not overlap.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/geo/bbox-union

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/geo/bbox-union \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"min_lat_a":40.7,"max_lat_a":40.8,"min_lon_a":-74.1,"max_lon_a":-73.9,"min_lat_b":40.75,"max_lat_b":40.9,"min_lon_b":-74.05,"max_lon_b":-73.85}'
{
  "min_lat_a": 40.7,
  "max_lat_a": 40.8,
  "min_lon_a": -74.1,
  "max_lon_a": -73.9,
  "min_lat_b": 40.75,
  "max_lat_b": 40.9,
  "min_lon_b": -74.05,
  "max_lon_b": -73.85
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "geo.bbox_union",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Enter eight finite decimal-degree corners (min and max lat and lon for box A and box B); the tool returns the union min_lat, max_lat, min_lon, max_lon, a GeoJSON-style bbox array [west, south, east, north], width and height in degrees, degree-squared area, the center point, the echoed input boxes, a relation flag for identical or nested cases, and step-by-step derivation lines. Inverted boxes and out-of-range coordinates fail with invalid_input so callers never ship a silently swapped range.

How to call the API and what comes back

Latitude fields must lie in the closed interval from minus ninety to ninety; longitude fields must lie in the closed interval from minus one hundred eighty to one hundred eighty. Send a JSON body with eight required finite numbers: min_lat_a, max_lat_a, min_lon_a, and max_lon_a for the first box, and min_lat_b, max_lat_b, min_lon_b, and max_lon_b for the second. Within each box, min_lat must be less than or equal to max_lat and min_lon must be less than or equal to max_lon. Canonical names accept aliases such as south_a, north_a, west_a, east_a and the corresponding _b forms, plus lat_min_a style alternates, so existing clients can map common GIS field names without a rewrite. On success the response sets min_lat, max_lat, min_lon, and max_lon for the union; sets bbox to the four-tuple min_lon, min_lat, max_lon, max_lat in west-south-east-north order; sets width_deg, height_deg, and area_deg2 from simple degree arithmetic; sets center_lat and center_lon to the midpoint of the union; echoes box_a and box_b with rounded corners; sets relation to identical, a_inside_b, b_inside_a, or partial_or_disjoint; sets message to a short English summary; and sets steps to an ordered array of derivation lines you can show in logs or UI. Failed validation—missing fields, non-finite numbers, latitude or longitude out of range, or an inverted min greater than max—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item.

Practical tips, limits, and related searches

Keep both boxes in the same geographic CRS and decimal degrees; do not mix web-mercator meters with lat/lon degrees in the same call. Near the poles a degree of longitude is short in meters, so use the union for indexing and viewport framing, then refine with projected or geodesic measures if you need physical area. Prefer this capability when you already hold two axis-aligned envelopes and only need the containing rectangle; if your source is a multipoint set, compute a multipoint bbox instead. Remember that a degree-based envelope is not a true geodesic area: width_deg and height_deg are angular spans, and area_deg2 is their product for quick comparisons, not square meters on the ellipsoid. For Pacific-centered work near the antimeridian, ensure each input already has min_lon less than or equal to max_lon in the unwrapped sense you chose; this tool does not invent a dateline-crossing multipolygon, because the product contract is explicit component-wise min and max. Pair examples: two overlapping Manhattan neighborhoods that expand both south and east edges; a small box nested inside a city-scale box where relation is a_inside_b; and a deliberately inverted box that demonstrates the hard invalid_input path. This landing targets people searching for bounding box union, merge two bounding boxes, lat lon envelope of two boxes, or combined geographic extent; it is not a point-radius buffer, not a geohash encoder, and not a polygon dissolve. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately send inverted ranges. Round-trip checks are easy: recompute min of the two min_lat values by hand and confirm the response matches within the published twelve-decimal rounding.

Offline pack and export extent planning

Given two region packs already described as lat/lon boxes, compute the combined download or print extent deterministically for CI fixtures.

How is the union bounding box computed?

Component-wise extremes: min_lat is the smaller of the two southern edges, max_lat the larger northern edge, min_lon the smaller western edge, and max_lon the larger eastern edge. That is the smallest axis-aligned box containing both inputs.

What if one box is completely inside the other?

The union equals the outer box. The response sets relation to a_inside_b or b_inside_a so clients can detect nesting without extra checks.

Read the full KIT documentation →