The only built-in spatial operation as of Neo4j 4.0 is the distance function, which computes the distance between two points. It can be used in the following way:
RETURN distance(point({latitude: 45, longitude: 3}), point({latitude: 44, longitude: 2}))
According to this function, the distance between these two random points in France is 136,731 meters, that is to say, around 137 km (approximately 85 miles).
The two points in the distance function need to be in the same CRS!
The result is in meters if the two points were in the GPS projection, otherwise the unit depends on the unit of the projection.
The result is in meters if the two points were in the GPS projection, otherwise the unit depends on the unit of the projection.
Let's use this function in a more realistic example. We are going to use the NYC_POI.csv dataset we imported in the previous section to get the five closest points of interest from a given point, for instance, Times Square, whose GPS coordinates are (40.757961, -73.985553):
MATCH (n:POI)
WITH n, distance(n.point, point({latitude: 40.757961, longitude...