Neo4j Spatial & NearestNeighborSearch

75 views
Skip to first unread message

Ben

unread,
Feb 2, 2012, 5:38:22 PM2/2/12
to Neo4j
I can't seem to find a solution to this one. Really appreciate any
help:

I'm using a GeoPipeline NearestNeighborSearch to find the closest
spatial-aware Vertex to a given Coordinate. The Layer is from an
imported OSM-file.
Problem is, that the Pipeline returns the GEOM node that the vertex
belongs to, the road for instance which handles information for the
whole Geometry. I'd rather like to get the specific node to make
further calculations/traversals on/from this one.
Creating a DynamicLayer to handle only Point geometries doesn't seem
to be a good solution, as I'd like to traverse the graph from this
specific node.

Gist:
https://gist.github.com/1726156

Thanks in advance!

Ben

unread,
Feb 3, 2012, 5:28:01 AM2/3/12
to ne...@googlegroups.com
I attached a snapshot which may help to understand what I'm asking for.

If I start a NearestNeighborSearch via GeoPipeline with say Coordinates like:

Lat 51.03475

Lon 13.7219


The result I can extract from the Pipe will typically be the GEOM Node which holds information of the whole geometry object. (BBox, Gtype, etc.) See upper right corner.

What I am really looking for here is the Node which holds the lat/lon properties closest to the given position?


I guess the problem is, that the standard RTree indexes the GEOM node by its bounding box?

Bernhard.jpg

Peter Neubauer

unread,
Feb 3, 2012, 10:11:35 AM2/3/12
to ne...@googlegroups.com
yes,
exactly. In this case, you would need to import the points also as
first class geometries which will index them in the RTree and give you
the results. Or, you can traverse from the Geometry node and examine
the points, maybe using another custom pipe that you can send a pull
request on when it is done :)

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 1.6 released                 - dzone.com/6S4K
The Neo4j Heroku Challenge   - http://neo4j-challenge.herokuapp.com/

Ben

unread,
Feb 3, 2012, 11:23:27 AM2/3/12
to ne...@googlegroups.com
I decided for the second solution as I didn't want to touch the dataset or introduce an even bigger index.
Code is a bit ugly though and not a pipe. I will try to clean/rewrite it and hand it over later if it is of interest.

Peter Neubauer

unread,
Feb 3, 2012, 11:24:16 AM2/3/12
to ne...@googlegroups.com
Yes,
please. More eyes on spatial are very needed!

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

Neo4j 1.6 released                 - dzone.com/6S4K
The Neo4j Heroku Challenge   - http://neo4j-challenge.herokuapp.com/

Reply all
Reply to author
Forward
0 new messages