0

I am new to neo4j & using neo4j version 3.3.2 neo4j spacial branch - 0.25-neo4j-3.3

Could you provide a code snippet to import osm file?

I have tried https://github.com/maxdemarzi/OSM . Neo4j spacial ReadMe(Importing an Open Street Map file) example does not work.

/Thanks

user3478108
  • 17
  • 1
  • 1
  • 9

1 Answers1

1

You can just install the Neo4j Spatial plugin and run the cypher query for import:

CALL spatial.addLayer('layerTestName', 'osm', '')
CALL spatial.importOSMToLayer('layerTestName', '/path/to/file.osm')

Java example (from doc):

OSMImporter importer = new OSMImporter("/path/to/file.osm");
importer.setCharset(Charset.forName("UTF-8"));
BatchInserter batchInserter = getBatchInserter();
importer.importFile(batchInserter, "map.osm", false);
//batchInserter.shutdown();
//GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(databasePath);
reActivateDatabase(false, false, false);
GraphDatabaseService db = graphDb();
importer.reIndex(db);
db.shutdown();
stdob--
  • 28,222
  • 5
  • 58
  • 73