Functions / PostGIS / ST_XMin
PostGISBounding Box

ST_XMin

What is ST_XMin?

ST_XMin is a PostGIS accessor that returns the minimum X (easting / longitude) coordinate of a geometry's bounding box.

SQL
1ST_XMin(geometry geom)float
2ST_XMin(box3d box)float

When would you use ST_XMin?

Use ST_XMin whenever you need the left edge of a geometry's extent — partitioning or binning data by longitude, emitting WMS BBOX strings, computing tile coordinates, or performing custom spatial quality checks.

SQL
1SELECT name,
2       ST_XMin(geom) AS west_edge,
3       ST_XMax(geom) AS east_edge
4FROM regions
5ORDER BY west_edge;

FAQs

What's the value for an empty geometry?

Empty geometries have no bounding box, so ST_XMin returns NULL. Always handle this case in reporting queries, for example with COALESCE or an IS NOT NULL filter.

Is ST_XMin expensive on complex geometries?

No — PostGIS caches the bounding box on every geometry, so ST_XMin is a constant-time lookup regardless of vertex count. You can call it repeatedly without a performance concern.

Can I use ST_XMin on a box3d?

Yes — there is an overload for box3d that returns the min X component. Handy when you already have a box3d from an aggregate like ST_3DExtent.

How does ST_XMin differ from the minimum X of individual vertices?

They are the same value for non-curved geometries. For circular strings and curve-containing geometries, PostGIS computes the bounding box from the actual curve extent, which may go beyond any individual control-point X.