Turf.jsMeasurement

turf.bboxPolygon

What is turf.bboxPolygon?

turf.bboxPolygon takes a bounding box array [minX, minY, maxX, maxY] and returns a GeoJSON Polygon Feature whose exterior ring traces the four corners of that box. It is the inverse companion to turf.bbox and is the easiest way to materialise an extent as drawable geometry.

JavaScript
turf.bboxPolygon(bbox, options?) → Feature<Polygon>

Options include:

  • properties — object assigned to the output feature's properties
  • id — value assigned to the output feature's id

When would you use turf.bboxPolygon?

Use turf.bboxPolygon when you need to render a bounding box on a map — for example, highlighting a search extent, visualising tile boundaries, or showing the region a user is filtering by. Paired with turf.bbox, you can convert any feature into its axis-aligned envelope and add it as a GeoJSON source on MapLibre or Mapbox in two lines.

It is also useful for spatial joins and clipping in Node.js — generate a polygon from a bbox, then pass it to turf.intersect, turf.bboxClip, or turf.booleanContains to filter features without hand-rolling the geometry.

Code
undefined

FAQs

What coordinate order does turf.bboxPolygon expect?

[west, south, east, north] — the same order GeoJSON uses for its bbox member and what turf.bbox returns. Passing [minLng, minLat, maxLng, maxLat] is equivalent.

Can I attach properties to the resulting polygon?

Yes. Pass { properties: { … } } as the second argument. You can also pass id to set the feature's top-level id. Both are standard Turf helper options used across feature-constructing functions.

Does the polygon follow the WGS84 right-hand rule?

Yes, assuming the input bbox has minX < maxX and minY < maxY. The ring is ordered counter-clockwise in geographic space, so it is compliant with the GeoJSON 2016 spec without needing a subsequent turf.rewind.

How do I install just bboxPolygon?

npm install @turf/bbox-polygon. It has no runtime dependencies beyond @turf/helpers, so it is an ideal pick when you want a small client-side bundle.