cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How i can import nodes on spatial layer

 

Hi, i have to import the nodes 'Linea', taken from a json file, into the 'spatial' layer  i created:Immagine 2022-12-12 180354.png but unfortunately, running the script on the prompt, i get this error.

Immagine 2022-12-12 181141.png

Can you help me?

The nodes not are simple points, but they have a geometry wkt with type MultiLineString and coordinates.

10 REPLIES 10

What is the error?

I don't get it, I put it back in the prompt image.
It tells me "java.lang.NullPointerException" and doesn't execute me "spatial.addNode", not reporting consequently the nodes in the spatial layer.
Thank you very much for helping

Which query is causing the NPE?  You have three?  The NPE must be occurring within one of the method or function calls.

just a few comments:

1) you have a sequence of ‘unwinds’. This will cause the Cartesian product of all the events of all the lists you are unwinding. As a result, I think you are getting the same list of points for each value of property. What does the jso look like? Maybe we can figure out the best way to extract the data 

2) the ‘points’ variable will be a list, since it is created by collecting data. You then try to convert it to a string. This should have an issue.

3) in the last query, you are matching to get nodes ‘l’, then collecting into list ‘lines’, then unwinding to ‘n’.  All this is unnecessary, since you will end up with the same rows as created from the match.  As such, you could just match and pass ‘l’ to the addNodes method. 

It gives me the NPE when running the third query, the one with spatial.addNode.
The json file looks like this, what could I have done wrong?

 

this is the example of a node:

Immagine 2022-12-13 104047.png

the NPE must be occurring in the spatial.addNode method. What is the method doing?  I suspect it needs data in one or more properties and you are not providing at least one of those properties.   When the missing property is accessed it is null, and that is causing a problem in the method’s code. 

What is the method doing so we can figure out the issue?  

The spatial.addNode should add nodes to the spatial layer, created in the above query with the spatial.addWKTLayer('spatial', 'geometry') method.
Maybe it can't access the 'geometry' property, but I don't understand what I could have done wrong with importing the multilinestrings. Seeing the json file, how would you import them?

The geometry property is set to the value of pointString, which is set using the apoc method.  The issue here is that you are passing a list to convert to a string. The method will convert a list such as [1,2,3] to ‘[1,2,3]’.  What is the structure if the data that addWKTLayer expects for the ‘geometry’ property?  Is there documentation I can read? 

The multilinestring data structure I need to import is this:

Immagine 2022-12-13 104047.png 

But what does the addNode method expect of the property ‘geometry’?  

But I don't know, maybe it's related to spatial.addWKTLayer; I've never done such a thing before and took a cue from https://neo4j-contrib.github.io/spatial/0.24-neo4j-3.1/index.html.
Anyway, how would you import multilinestrings, how would you create a 'geometry' property with wkt geometry?