first time posting here... sorry if this is a repeat question, but I've searched without any luck so far 😞
I've been battling for a while now trying to import an OSM file into a DB using neo4j-desktop.
The closes command I can see as being applicable is the "CALL spatial.importOSM()",
(Going Spatial: Leverage Geospatial Data with Neo4j 3.4 - YouTube, found here, thanks to Craig and William for your eagerness to share your wealth of knowledge!!)
Is there a trick to importing OSM Data? Can it be done in Desktop or only using Java?
Any help will be greatly appreciated
Thanks in advanced
Solved! Go to Solution.
Hi, if you need a docker based solution, i can point to my blog.
The neo4j-spatial-0.26.2 doesn't work on Neo4j 4.x, it works only on Neo4j 3.x (x = 2,3,4)
Let me know if you need assistance.
Hi @edurodmic001 , I usually use Linux and not windows. So, the below steps are for Linux.
Download spatial plugin from https://github.com/neo4j-contrib/spatial/releases/download/0.26.2-neo4j-3.5.2/neo4j-spatial-0.26.2-n... and copy it to the plugins folder. (The link to jar file is changed now after comment from Craig. Wrong link was pasted here before).
Update the neo4j.conf file as
Start the neo4j insance
Download an area from https://extract.bbbike.org/ with the format type -> OSM.
Extract the OSM and place it in a folder with .osm format.
Open the cypher-shell or browser and execute -> CALL spatial.importOSM("/maps/india.osm");
It will take a while depending upon the size of the OSM file. My maximum file size was 50MB, so it took around 5-10 mins.
The above steps were tested on Neo4j 3.x. From the release notes, they have mention that spatial pluging will work on neo4j 4.x also, but i haven't tested. I have created my own custom loader for loading osm files.
Last but not least, try this one also -> https://openmaptiles.org/
Let me know how this works.
Dominic's advice above is good, although you should take care to match the correct versions of Neo4j. So for the plugin above you must download Neo4j 4.2. It will not work on Neo4j 3.5. Each plugin has the version of neo4j for which it was built included in the plugin name. So
neo4j-spatial-0.28.0-neo4j-4.2.3-server-plugin.jar was built with Neo4j 4.2.3. It should work with any version of Neo4j 4.2, but because of the use of internal API's, it might not work with all Neo4j 4.2.x. But it most certainly will give problems on Neo4j 4.1, or 4.0, and definitely will not work at all on Neo4j 3.5.
If you have an already running version of Neo4j, then look at the spatial releases on the page at Releases · neo4j-contrib/spatial · GitHub, and choose one that is closest to the version of Neo4j you are using.
Also, take note that the procedure
spatial.importOSM can only import one OSM file. If you plan to import more than one file, then you need to use the 0.28 version, and the procedure
And finally, if you wish to import large OSM files quickly, it is better to use the external offline import tool at GitHub - neo4j-contrib/osm: OSM Data Model for Neo4j. It is much faster and can import much larger OSM files.
Hi @craig.taverner , just now I reviewed my post. The plugin is https://github.com/neo4j-contrib/spatial/releases/download/0.26.2-neo4j-3.5.2/neo4j-spatial-0.26.2-n... . I think I copied the wrong release link
thanks a lot for your support. The error I was getting was a FileNotFoundException, no matter what file-path I entered or where I put the .osm file.
For example, using Neo4jDesktop Enterprise running on Windows 10:
Failed to invoke procedure `spatial.importOSM`: Caused by: java.io.FileNotFoundException: map.osm (The system cannot find the file specified)
I'm guessing I'm just referencing the file wrong? Or am I storing it in the wrong place?
I did, however, have more success with apoc.load.xml with the file in the same directory, but I'm guessing importosm would require a lot less post-processing to get the info from the nodes than load.xml?
I'll try your suggestions tonight and see how they go