Spatial Data Types

Cypher has built-in support for handling spatial values (points), and the underlying database supports storing these point values as properties on nodes and relationships.

https://neo4j.com/docs/cypher-manual/current/syntax/spatial/

Cypher Type

Python Type

Point

neo4j.spatial.Point

Point (Cartesian)

neo4j.spatial.CartesianPoint

Point (WGS-84)

neo4j.spatial.WGS84Point

Point

class neo4j.spatial.Point(iterable)

Bases: Tuple[float, …]

Base-class for spatial data.

A point within a geometric space. This type is generally used via its subclasses and should not be instantiated directly unless there is no subclass defined for the required SRID.

Parameters:

iterable (Iterable[float]) – An iterable of coordinates. All items will be converted to float.

Return type:

Point

srid: int | None

The SRID (spatial reference identifier) of the spatial data. A number that identifies the coordinate system the spatial type is to be interpreted in.

CartesianPoint

class neo4j.spatial.CartesianPoint(iterable)

Bases: Point

Parameters:

iterable (t.Iterable[float])

Return type:

Point

property x: float

Same value as point[0].

property y: float

Same value as point[1].

property z: float

Same value as point[2].

Only available if the point is in 3D space.

Examples

from neo4j.spatial import CartesianPoint

point = CartesianPoint((1.23, 4.56))
print(point.x, point.y, point.srid)
# 1.23 4.56 7203
from neo4j.spatial import CartesianPoint

point = CartesianPoint((1.23, 4.56, 7.89))
print(point.x, point.y, point.z, point.srid)
# 1.23 4.56 7.8 9157

WGS84Point

class neo4j.spatial.WGS84Point(iterable)

Bases: Point

Parameters:

iterable (t.Iterable[float])

Return type:

Point

property x: float

Same value as point[0].

property y: float

Same value as point[1].

property z: float

Same value as point[2].

Only available if the point is in 3D space.

property longitude: float

Alias for x.

property latitude: float

Alias for y.

property height: float

Alias for z.

Only available if the point is in 3D space.

Examples

from neo4j.spatial import WGS84Point

point = WGS84Point((1.23, 4.56))
print(point.longitude, point.latitude, point.srid)
# 1.23 4.56 4326
from neo4j.spatial import WGS84Point

point = WGS84Point((1.23, 4.56, 7.89))
print(point.longitude, point.latitude, point.height, point.srid)
# 1.23 4.56 7.89 4979