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
    • Graphs with Edge ID
    • Graph Types
    • Constraints
    • Projections
    • Storage Maintenance
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • MERGE
    • SET
    • REMOVE
    • DELETE
    • FOREACH
    • 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
    • Database Functions
  • Operators
  • Predicates
    • CASE
    • LET Value Expression
    • Value Query Expression
    • List Expressions
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
  • Execution Plan
  • Backup and Restore
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Naming Conventions
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

Spatial Functions

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 two-dimensional geographical coordinate.

Syntaxpoint(<longitude>, <latitude>)
ArgumentsNameTypeDescription
<longitude>NumericThe longitude value, ranging from -180 to 180
<latitude>NumericThe latitude value, ranging from -90 to 90
Return TypePOINT
GQL
RETURN point(116.3, 39.9) AS point

Result:

JSON
{
  "longitude": 116.3, "latitude": 39.9
}

point3d()

Creates a three-dimensional Cartesian coordinate.

Syntaxpoint3d(<x>, <y>, <z>)
ArgumentsNameTypeDescription
<x>NumericThe x coordinate
<y>NumericThe y coordinate
<z>NumericThe z coordinate
Return TypePOINT3D
GQL
RETURN point3d(10, 15, 5) AS point3d

Result:

JSON
{
  "x": 10, "y": 15, "z": 5
}

distance()

Computes the distance between two points. For POINT values, it uses the Haversine formula to calculate the great-circle distance on Earth in kilometers. For POINT3D values, it computes the Euclidean distance.

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: 5570.833653336143

pointget()

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

Syntaxpointget(<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 pointget(n.location, 0) AS longitude, pointget(n.location, 1) AS latitude

Result:

longitudelatitude
-74.040.7