After a some tests and research this is what I came up with:
Neo4j-OSM is a Importer and Model for OSM Data optimised for routing. There is no spatial index included, the spatial index of Neo4j for Points can be used. Here an offline Importer, via commandline, enables fast Imports for Neo4j-Server (See Java command above).
Neo4j-Spatial is an Importer an Model with an RTREE Spatial Index, like Postgis. Spatial functions like Within, Intersect or Contains can be executed. The Modell is a different one to Neo4j-OSM and not suitable for routing. For importing there are two ways:
- Import via Java Application but only for embedded use (?)
OSMImporter importer = new OSMImporter("sweden");
Map<String, String> config = new HashMap<String, String>();
config.put("neostore.nodestore.db.mapped_memory", "90M" );
config.put("dump_configuration", "true");
config.put("use_memory_mapped_buffers", "true");
BatchInserter batchInserter = BatchInserters.inserter(new File(dir), config);
importer.importFile(batchInserter, "sweden.osm", false);
batchInserter.shutdown();
GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(dir);
importer.reIndex(db, 10000);
db.shutdown();
GraphDatabaseService does not exists in the Java Driver for Neo4j-Server. Is there a Way to make this Java code work with the Neo4j-Server Java driver ?
- Import with procedure:
CALL spatial.importOSM(osmfile);
This worked for a small file in Neo4j-4.1.6 and I think newer Versions will work to. This enabled the Import to an Neo4j-Server, but it’s really slow (which was mentioned by @craig.taverner in this post.
How can I Import larger files with the Neo4j-Spatial Model ?
Th Neo4j-OSM README says
- Can replace the older OSMImporter in Neo4j Spatial (ie. should work with Neo4j Spatial also).
But the two Models are completely different, for an example:
Neo4j-OSM:
- no layers
- only spatial index for point geometries
- Relations have „member“-relations to assign members
Neo4j-Spatial:
- RTREE spatial index
- layers with more komplex geometries than Points
- relations only have tags and name (?)
The only similarity I see is the structure of ways and nodes.
So how are these two Importers compatible? Can I create a OSMLayer in the Neo4j-OSM Model ? Or can I use the routeIntersection from Neo4j-OSM in the Neo4j-Spatial Model ?
Many questions, sorry but I’m really confused by this statement