Spatial functions and geometry semantics#

Use this reference to interpret spatial results and refusals. SQL admission depends on the overload, argument types and query shape. Admission alone does not establish that every geometry family and argument combination has a native execution route. The generated admission index in Spatial SQL and query-shape support is the exact SQL overload authority. For Python declarations and active-column delegates, see Python objects and dataframe operations.

Coordinates and units#

Geometry operations are planar: they operate in the input coordinate units. For example, planar distance is in those units and area is in their square. Assigning a coordinate system does not itself transform coordinates. See How coordinates determine distance and area for the implications of working in geographic coordinates.

WGS 84 geography casts provide geodesic distance operations. ST_Distance returns metres and ST_DWithin tests a threshold in metres for Point, LineString, Polygon, their Multi families and nested GeometryCollection. Their optional use_spheroid boolean defaults to true. false selects a sphere. The optional boolean is strict, so NULL is honored. These rules do not establish geography area support or acceptance of other geographic coordinate systems. See the geography distance tests, geography distance-within tests, and geography family tests.

SQL functions#

The following groups provide a route into the operation you need. Consult the generated SQL index for exact signatures, axes, family and literal restrictions, and result types. The scalar declarations define the frontend signatures. The geometry function tests probe representative forms.

Constructors and encoding#

Constructors such as ST_MakePoint and ST_GeomFromWKB produce geometry values. Text and binary encoding operations expose geometry for interchange. Use the generated index to check the input type and accepted form before constructing a value. An untyped text value is not automatically an accepted geometry operand for every operation.

ST_MakeLine(a, b) constructs a planar XY LineString from two Points, each a row value or a constant. GPU execution can return the line or pass it to consumers such as ST_NPoints, ST_Intersects and ST_Distance; each consumer retains its own input limits. A NULL endpoint gives NULL. EMPTY endpoints contribute no vertices: one EMPTY gives a one-vertex line, and two give LINESTRING EMPTY. Present endpoints with different SRIDs, including EMPTY, raise CUGEO_GEOMETRY_CUDF_MIXED_SRID (SQLSTATE XX000) when the row is demanded. A NULL endpoint suppresses the mismatch; guards, filters and LIMIT can leave a row undemanded. ST_Length(ST_MakeLine(a, b)) measures the Point pair directly without materializing the line. See the MakeLine contract and live tests.

Inspection and planar measures#

ST_Area(geometry) returns planar area in squared input-coordinate units. ST_ConvexHull(geometry) returns a geometry representing the convex hull. The frontend tests bind these forms for a polygon geometry column, but reject integer operands and untyped text in the tested calls. The tests also reject untyped NULL for these calls. Use an explicitly typed geometry NULL where a geometry operand is required.

Inspection operations include geometry type, emptiness, point counts and coordinate extrema. Their output describes the stored geometry, so a ring’s repeated closing coordinate contributes to its point count.

Predicates and distances#

Planar predicates describe relationships in the input coordinate space. For example, ST_Touches(geometry, geometry) tests whether geometries touch. ST_DistanceSphere has tested two-geometry and three-argument forms. The latter takes a numeric sphere radius. The frontend tests reject a non-geometry operand, a text radius and a one-argument call. Check the generated index and execution restrictions for the particular operand families rather than assuming that a bound call covers every family.

For WGS 84 geography, use ST_Distance or ST_DWithin for the metre-based behavior described above. For why a predicate can exclude a row even when bounds overlap, see Why a geometry can have bounds and still fail a predicate.

Buffer and overlay#

ST_Buffer(geometry, distance) returns a geometry. The frontend tests also bind a text style form, including the literal 'quad_segs=8'. A style read from a column is refused in the tested form. A bound style does not by itself guarantee that its options and operand combination are executable. Buffer distance uses planar input-coordinate units. Check the generated index for the admitted overload and the execution restrictions for the selected geometry and style.

Overlay operations produce geometries from spatial combinations of their inputs. Check the operation and both operand families in the index before relying on a particular route.

Collect and aggregate#

ST_Collect(g) runs as a grouped or keyless aggregate. Return its geometry, pass it through a subquery or use it with a scalar operation that admits the resulting family. It accepts XY Point, LineString, Polygon and their Multi families. GeometryCollection inputs and members with Z or M ordinates raise a missing-capability refusal. It ignores NULL members and returns NULL when a group has no present members. It preserves duplicates, typed EMPTY values, coordinates, SRID and Multi nesting.

ST_ConvexHull(ST_Collect(point)) can return the hull or feed another admitted scalar. If the query reads the collection only through its convex hull, the engine can keep each group’s hull candidates instead of every Point and spill them when needed. If the query only reads the collection’s envelope, the engine can aggregate bounds, retaining EMPTY members when the envelope preserves the collection. When fusion is disabled, the ordinary operations run separately. See the collection contract for the limits.

Repair#

ST_MakeValid has geometry and geometry-plus-text forms in the frontend. An integer geometry operand or integer parameter does not resolve to that overload. In the tested optional-style forms, strings such as 'method=linework' and 'method=structure keepcollapsed=false' are classified as unadmitted forms. Invalid option strings bind so that row demand determines whether the operation-body error occurs. A NULL argument suppresses that error under the strict NULL rule. This frontend behavior is not a claim that the valid styles have a native repair route.

Coordinate transforms#

ST_Transform changes coordinates to a target SRID. Its target’s form matters as well as its type. The following outcomes are established by the frontend transform tests. They do not by themselves establish native execution for a CRS pair.

Target argument

Compilation outcome

Native route

Integer literal, for example 3857

Exercises the admitted literal form

Check the source and target CRS and execution support separately.

Bare NULL

Strict NULL result. No transform call is emitted.

No transform is run for that expression.

NULL::integer

Refused as an unsupported nonliteral target in the checked test

No native route is selected.

Integer column, for example target

Can pass type checking but is refused as an unsupported nonliteral target

No native route is selected.

Wrong type, for example true or 1::bigint

Overload resolution reports an undefined function in the checked tests

No native route is selected.

Strict NULL handling also applies when the geometry operand is NULL. Operation-body errors are guarded by expression demand: a branch that is not evaluated need not execute the transform. For a requested transform that does execute, consult Coordinate systems and operation selection for operation selection.

GeoSeries operations#

The generated Python index in Python objects and dataframe operations is the declaration lookup for GeoSeries and for the operations exposed by a GeoDataFrame through its active geometry column. The summaries below describe common results and edge values. Check the index and operand restrictions for the operation you intend to call.

Purpose

GeoSeries lookup

Result or interpretation

Measure

area, length, bounds, count_coordinates, total_bounds, distance

Numeric values or bounds. Area and length are planar in source-coordinate units. Area uses squared units.

Test a relationship

intersects, within, contains, covers, covered_by, touches, disjoint, dwithin

Boolean relationship results.

Construct geometry

centroid, envelope, buffer

A geometry result retaining the source CRS.

Inspect state

geom_type, is_empty, isna, notna

Geometry type or boolean state.

Select or export

Row and index selection and export methods

See the generated Python index for the available members and return types.

centroid is a planar XY operation. NULL stays NULL. EMPTY becomes Point EMPTY. A geographic CRS produces a warning and coordinates are not transformed.

count_coordinates() returns a cuDF int32 Series of stored coordinate counts. NULL and EMPTY both yield zero. Ring closure is stored and counted: a polygon exterior with four distinct corners has five coordinates when its first coordinate is repeated at the end.

Buffer and envelope#

buffer(distance, resolution=16, cap_style="round", join_style="round", mitre_limit=5.0, single_sided=False) produces planar XY polygonal geometry in source-coordinate units. The checked profile admits round, two-sided styles and integer resolution up to 65536. A nonpositive signed Int32 resolution means one segment per quadrant. Scalar NaN produces NULL, including for EMPTY input. Infinite distance raises ValueError when a geometry is present. A geographic CRS normally produces a warning. See the GeoSeries implementation and the generated index for the admitted geometry families and other argument restrictions.

envelope returns planar XY envelopes. A collapsed box can produce a Point or LineString. NULL and original EMPTY families and members are preserved. These operations retain the source CRS rather than transforming coordinates.

For detailed numeric comparisons and known deviations, see PostGIS comparison cases.