UltipaDocs
Try Playground
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Closed Graph
    • Open Graph
    • Graph Sharding and Storage
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • SET
    • REMOVE
    • DELETE
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Scalar Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Type Conversion Functions
    • Table Functions
    • AI & Vector Functions
    • Database Functions
  • Operators
  • Predicates
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
    • Process
    • Job
    • Execution Plan
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

Spatial Functions

Example Graph

The following examples run against this graph:

distance()

Computes the straight-line distance between two points.

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

Result:

distance(n1.location, n2.location)
5571177.78487926

point()

Constructs a two-dimensional geographical coordinate. The point() function can be used to specify the value of a point-type property.

Syntaxpoint({latitude: <lati>, longitude: <longti>})
ArgumentsNameTypeDescription
<lati>NumericThe latitude value
<longti>NumericThe longitude value
Return TypePOINT
GQL
RETURN point({latitude:39.9, longitude:116.3}) AS point

Result:

point
POINT(39.9 116.3)
GQL
INSERT (n:City {name: "Tokyo", location: point({latitude: 35.7, longitude: 139.7})})
RETURN n.location

Result:

n.location
POINT(35.7 139.7)

point3d()

Constructs a three-dimensional Cartesian coordinate. The point3d() function can be used to specify the value of a point3d-type property.

Syntaxpoint3d({x: <value_x>, y: <value_y>, z: <value_z>})
ArgumentsNameTypeDescription
<value_x>NumericThe x value
<value_y>NumericThe y value
<value_z>NumericThe z value
Return TypePOINT3D
GQL
RETURN point3d({x:10, y:15, z:5}) AS point3d

Result:

point3d
POINT3D(10 15 5)
GQL
INSERT (n:City {name: "Tokyo", landmark: point3d({x:10, y:15, z:5})})
RETURN n.landmark

Result:

n.landmark
POINT3D(10 15 5)

pointget()

Extracts the coordinate values in the point or point3d property.

Syntaxpoint3get(<propRef>, <coordName>)
ArgumentsNameTypeDescription
<propRef>/Reference to a point or point3d type property
<coordName>TextualCoordinate name; the point type is latitude or longitude, the point3d type is x, y or z
Return TypeDOUBLE
GQL
MATCH (n {name: "New York"})
RETURN pointget(n.location, "latitude") AS latitude, pointget(n.landmark, "y") AS y

Result:

latitudey
40.723