I have node A with 2 properties lat, lon. :A(lat : 11, lon : 12) and node B with 1 property polygon. :B (polygon : [[10, 11], [5, 7], [1, 2], ....]). how can I detect is A inside list point of polygon which is property of B??
2 Answers
Right now exists the "spatial-algorithms" library which, among other things, supports the recent geometry point specification "Point". Although there is a presentation that explains how this library works, I have not been able to find a manual on how to use it, however, following the simple steps of installing the library that we can find in the Github project, and reviewing the tests of the same project, it does not work very difficult to use it.
Specifically, to check that a point is inside a polygon we must do:
1.First we create the polygon with an array of geometric points belongs to node "place", in this case a triangle.
WITH
point({x: 0, y: 0}) AS p1,
point({x: 3, y: 3}) AS p2,
point({x: 6, y: 0}) AS p3
CREATE (n:Place{polygon:[p1,p2,p3]}) return n
2.We define this array as a polygon with the function "spatial.polygon".
3.And next we check that the point p1 is inside the polygon with the function "spatial.algo.withinPolygon"
MATCH (place) where ID(place)=290416
WITH
point({x: 3, y:10}) AS p1, place,
spatial.polygon(place.polygon) AS polygon RETURN spatial.algo.withinPolygon(p1,polygon)
You can see more information, such as geometric data indexing, here.

- 337
- 1
- 12
Neo4j spatial has support for this, be sure to read its user manual.

- 39,465
- 6
- 87
- 97