UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Questioned Paths
    • Shortest Paths
    • Cheapest Paths
    • K-Hop Traversal
    • Graph Patterns
    • Overview
    • Open Graphs
    • Closed Graphs
    • Graph Types
    • Constraints
    • Projections
    • Storage Maintenance
    • Node and Edge IDs
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • MERGE
    • SET
    • REMOVE
    • DELETE
    • FOREACH
    • LOAD CSV
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Element Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Null Functions
    • Utility Functions
    • Type Conversion Functions
    • Table Functions
  • Operators
  • Predicates
    • Overview
    • CASE
    • LET Value Expression
    • Value Query Expression
    • Count Query Expression
    • List Expressions
    • Current Values
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
  • Execution Plan
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Naming Conventions
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

Spatial Functions

Coordinate Reference Systems

POINT and POINT3D values carry a coordinate reference system (CRS), identified by an integer SRID. Four CRSs are supported:

SRIDCRS nameDimensionsDistance
4326wgs-842D (longitude, latitude)Great-circle (haversine), meters
4979wgs-84-3d3D (longitude, latitude, height)Haversine + height, meters
7203cartesian2D (x, y)Euclidean, raw coordinate units
9157cartesian-3d3D (x, y, z)Euclidean, raw coordinate units

The CRS determines how distance() is computed. Two points must share the same CRS to be compared.

Example Graph

GQL
INSERT (paris:City {name: "Paris", location: point(2.4, 48.9), landmark: point3d(100, 25.3, 652.1)}),
       (newYork:City {name: "New York", location: point(-74.0, 40.7), landmark: point3d(95, 23, 54)}),
       (london:City {name: "London", location: point(-0.13, 51.5), landmark: point3d(5.2, 66, 3.2)}),
       (newYork)-[:Connects]->(paris),
       (newYork)-[:Connects]->(london),
       (paris)-[:Connects]->(london)

point()

Creates a POINT (2D) or POINT3D (3D when a z/altitude/height key is present in the map form) value.

Syntaxpoint(<longitude>, <latitude>) or point(<map>)
ArgumentsFormBehaviorCRS
Positional (longitude, latitude)Two numeric arguments.Always wgs-84 (SRID 4326).
Map ({...})Single map literal with coordinate keys (and optional crs/srid).Inferred from keys; overridable.
Return TypePOINT, or POINT3D when the map carries a third coordinate.

Map form rules:

  • Coordinate keys (aliases are interchangeable):
    • 1st: x / longitude / lng
    • 2nd: y / latitude / lat
    • 3rd (optional, promotes to POINT3D): z / altitude / height
  • CRS inference (when neither crs nor srid is given):
    • Any geographic key (longitude/latitude/lng/lat/height) → wgs-84 (or wgs-84-3d if 3D).
    • Otherwise → cartesian (or cartesian-3d if 3D).
  • Explicit override: crs: '<name>' or srid: <number>. CRS must match the dimensionality of the coordinates.
GQL
-- Positional: WGS-84 by default
RETURN point(116.3, 39.9)

-- Map form, WGS-84 inferred from key names
RETURN point({longitude: 116.3, latitude: 39.9})

-- Map form, cartesian inferred from x/y
RETURN point({x: 1.5, y: 2.5})

-- Map form with z promotes to POINT3D (cartesian-3d)
RETURN point({x: 1, y: 2, z: 3})

-- Map form with height promotes to POINT3D (wgs-84-3d)
RETURN point({longitude: 116.3, latitude: 39.9, height: 100})

-- Explicit CRS override
RETURN point({x: 1.5, y: 2.5, crs: 'wgs-84'})
RETURN point({x: 1.5, y: 2.5, srid: 4326})

point3d()

Creates a POINT3D value. Same map-form rules as point(); the map argument must include the third coordinate.

Syntaxpoint3d(<x>, <y>, <z>) or point3d(<map>)
ArgumentsFormBehaviorCRS
Positional (x, y, z)Three numeric arguments.Always cartesian-3d (SRID 9157).
Map ({...})Single map literal with three coordinate keys (and optional crs/srid).Inferred from keys; overridable.
Return TypePOINT3D
GQL
-- Positional: cartesian-3d by default
RETURN point3d(10, 15, 5)

-- Map form, cartesian-3d inferred from x/y/z
RETURN point3d({x: 10, y: 15, z: 5})

-- Map form, wgs-84-3d inferred from longitude/latitude/height
RETURN point3d({longitude: 116.3, latitude: 39.9, height: 100})

-- Explicit CRS override
RETURN point3d({x: 1, y: 2, z: 3, crs: 'wgs-84-3d'})

distance()

Computes the distance between two points. The formula is chosen by the CRS the points carry (not by Go type):

  • Geographic (wgs-84, wgs-84-3d) — great-circle (haversine) distance in meters. The 3D form adds the height difference (Pythagoras).
  • Cartesian (cartesian, cartesian-3d) — Euclidean distance in the raw coordinate units.

Both points must share the same CRS, otherwise the call errors.

Syntaxdistance(<point1>, <point2>)
ArgumentsNameTypeDescription
<point1>POINT or POINT3DThe first point
<point2>POINT or POINT3DThe second point; must be the same type as <point1>
Return TypeDOUBLE
GQL
MATCH (n1:City {name: 'New York'})
MATCH (n2:City {name: 'London'})
RETURN distance(n1.location, n2.location)

Result: 5570833.653336142 (meters)

point_get()

Extracts a coordinate value from a POINT or POINT3D value by index.

Syntaxpoint_get(<point>, <index>)
ArgumentsNameTypeDescription
<point>POINT or POINT3DA point value
<index>INTCoordinate index. For POINT: 0 = longitude, 1 = latitude. For POINT3D: 0 = x, 1 = y, 2 = z.
Return TypeDOUBLE
GQL
MATCH (n {name: "New York"})
RETURN point_get(n.location, 0) AS longitude, point_get(n.location, 1) AS latitude

Result:

longitudelatitude
-74.040.7