Now that we have data inside our graph, we are going to use it to extract geographical information. More precisely, we will learn how to select nodes that lie within a certain distance from a given point. We will also discover a new functionality: the ability to find nodes contained within a polygon.
Finding the distance between two spatial objects
With neo4j-spatial, we can get nodes within a certain distance from another node. The procedure to perform this operation is called spatial.withinDistance and its signature is the following:
spatial.withinDistance(layerName, coordinates, distanceInKm) => node, distance
This means it will search, within a given layer, all points that are less than distanceInKm away from coordinates. It returns those nodes and the computed distance between the returned node and coordinates.
The coordinates parameter can be an instance of a point or a map of latitude and longitude.
For instance, we can find the point of interest located...