Reputation: 13
I'm trying to use Neo4j Spatial to do a distance calculation on a network. The goal is to define points within a certain distance but only point that are located on a road.
I loaded a SHP with my road network data using ShapefileImporter in Java. Now I can see a bunch of nodes with geometry property but I don't see any relationships.
How do I add relationships between connecting lines so that I have a real graph?
I had expected the the ShapeFileImporter would have taking start and endpoint for each line as a node and add relationship between both.
BTW, I'm using Neo4j Community 2.1.1 with Spatial 0.13 plugin.
Upvotes: 0
Views: 817
Reputation: 769
Each of the example importers provided with Neo4j Spatial makes a decision about how to structure that data in the graph. This decision is made by the choice of GeometryEncoder implementation. The GeometryEncoder decides how to structure the Geometry in the graph. The simplest generic choice for data sources that have all geometries separated, like Shapefile, is to just store each geometry as either WKT or WKB in a single property of a single node.
So, if you want to have geometries separated into graph structure, you would need to write an encoder for that. Or perhaps re-use or modify/extend one that already does that, like the OSMGeometryEncoder.
I think, however, the first question to ask yourself is why you want to see the geometry as a sub-graph? If it is to perform routing, for example, then this is not sufficient, you will also need to connect all the LineString segments together to create a complete network. In this case is it much easier to use an already connected dataset, like OpenStreetMap, which is already loaded into Neo4j as a fully connected graph.
If you specifically need to use Shapefiles, then the process would be:
Upvotes: 1
Reputation: 1128
I haven't played with it, but it looks like it takes each feature in the shapefile, imports each as a node, and allows spatial (within, overlap, intersect, etc) queries on it's properties via spatial index- not translating a layer of linesegments to nodes and relationships.
If you're going to translate road linesegments -> graph, remember that the roads would become the relationships, and the intersections of the roads would become the nodes.
Upvotes: 0