Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-31-2019 11:44 AM
I've manged to install the community edition of the spatial library and I'm attempting to add WKT cords to may WKT Layer. The nodes that have the the WKT properties have them stored in strings like:
'POLYGON((-96.30509799 36.18377966,-96.31404315 36.18379043,-96.31401013 36.1874649600001,-96.3050557399999 36.1874430600001,-96.30509799 36.18377966))'
When I attempt to add them to the layer with this query:
match(g:Layer)
call spatial.addNode('geom', g.wkt) yield node
return node
I get this error:
Neo.ClientError.Statement.TypeError: Can't coerce
String("POLYGON((-96.30509799 36.18377966,-96.31404315 36.18379043,-96.31401013 36.1874649600001,-96.3050557399999 36.1874430600001,-96.30509799 36.18377966))") to Node
I've tried a number of ways to format the string differently but can't get it to take. Should it be a different type of data type?
10-31-2019 12:58 PM
I swapped addNode for addWKT and this ran.
11-03-2019 07:02 AM
Since you already have a WKT property on a node, I think you do want to use spatial.addNode
, but you need to pass it the node, not the WKT, like CALL spatial.addNode('geom', g)
. When you created the layer geom
you should have configured it to know that the geometry can be found in wkt
properties of the nodes, so it would know to look for that property. For example, you would use CALL spatial.addWKTLayer('geom','wkt')
to make a layer called geom
with a WKT property called wkt
.
If you want to use spatial.addWKT
, that will create a new node for you, so the old node you already made will not be added to the spatial layer at all. Perhaps you want this, but I'm guessing it is not what you are after, so I suggest trying the spatial.addNode
with the right arguments.
11-03-2019 07:24 AM
I appreciate the reply, as stated, I tried add node and get the string coercion error that I posted. The signature of the procedure is :
"spatial.addNode(layerName :: STRING?, node :: NODE?) :: (node :: NODE?)"
Is it's refering to the ID of the node that contains the geometry?
11-17-2019 02:12 PM
As you pointed out in the signature, the procedure expects to be passed a node. However, the sample code you provided in the original question above does not pass a node, it passes a property (String), which leads to the correct error. For completeness let me copy in the example you provided:
match(g:Layer)
call spatial.addNode('geom', g.wkt) yield node
return node
Note the part where you pass in g.wkt
to the procedure. This is a String property, and not a node. If instead you passed only g
and the layer was configured to know that the wkt
property was the place to look, then you should not see this error.
All the sessions of the conference are now available online