spatial
spatial copied to clipboard
Is addGeometryWkt Procedure supports adding attributes to an WKT shape?
Hi, I am trying to import some polygons with other attributes like temperature and humidity. When using embedded API, it is possible to add properties using layer.add function. Now I am trying to use cypher procedure to add WKTs. is there any function provided to add WKTs as well as its properties?
Did you try to use this procedure?
spatial.addWKT
spatial.addWKT(layerName, geometry) YIELD node
On Fri, Feb 10, 2017 at 1:13 AM, kanghq [email protected] wrote:
Hi, I am trying to import some polygons with other attributes like temperature and humidity. When using embedded API, it is possible to add properties using layer.add function. Now I am trying to use cypher procedure to add WKTs. is there any function provided to add WKTs as well as its properties?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/neo4j-contrib/spatial/issues/294, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEHYz3a4kin8L2mVU6PzLwfz_rLeWWbks5ra6vHgaJpZM4L81nH .
There is a procedure spatial.setFeatureAttributes which does this. It will set the list of known attributes at the layer level. However, those should also exist as properties on the nodes you are indexing.
One issue I see here is that the current procedures for querying the database will return either nodes or geometries. None return the SpatialDatabaseRecord used in the embedded API, which provides the geometry and the attributes list together. The reason being that procedures can only return known Cypher types, or untyped objects. If we return a SpatialDatabaseRecord, it would not be usable within Cypher. You would then need additional functions to extract its contents.
This could look like:
CALL spatial.createWKTLayer('measurements','location');
CALL spatial.setFeatureAttributes('measurements',['temperature','humidity']);
CREATE (n:Measurement {location:'POINT(10.10 12.12)', temperature: 32.0, humidity: 78.0})
CALL spatial.addNode('measurements',n)
CALL spatial.withinDistance('measurements',{longitude:10.0,latitude:12.0},100) YIELD record
WITH spatial.getFeatureAttributes(record) as attributes
RETURN attributes['humidity'] as humidity, attributes['temperature'] as temperature
To support the above, we would need to add an extra 'record' colume to the withinDistance call, and it would be an untyped Object, only understood by a new user-defined-function spatial.getFeatureAttributes(record) which will pull out the attributes from the record.
If we don't want to involve record in this, we could also just add the layer name to the attributes method like this: spatial.getFeatureAttributes('measurements',n). That would work much the same.
What do you think?