Hey.
I have been importing a very large and complex json file. The last bit is giving me some problems.
I am trying to import a series of coordinates and create a polygon. The following is a representative section:
{
"name": "Test",
"type": "OFA",
"areas": [
{
"name": "Area1",
"type": "AO",
"areaId": "c797b1ad-0933-4e4c-8876-2a77b85464a5",
"geometry": {
"type": "POLYGON",
"coordinates": [
[
[
-77.29052240438029,
34.721088784223947
],
[
-77.47444321860393,
34.6875240918703
],
[
-77.44156351997177,
34.54401790721537
],
[
-77.29668734787383,
34.48442345344459
],
[
-77.17520021940087,
34.547199636055989
],
[
-77.24917954132323,
34.672210990230329
],
[
-77.29052240438029,
34.721088784223947
]
]
]
},
"description": "test area of ops"
}
],
"start": 1626825600000,
"mId": "74be7e16-a5d7-4557-a34b-b69fc5e6f59b",
"description": "Test",
"mArea": ""
}
The closest I can get is with this:
CALL apoc.load.json("test.json")
yield value as file
UNWIND file.areas as areas
UNWIND areas.name as areaName
UNWIND areas.type as areaType
UNWIND areas.areaId as areaId
UNWIND areas.geometry AS geometry
UNWIND geometry.coordinates as geometryCoordinates
UNWIND geometryCoordinates as geoCoord
WITH areaName, areaType, areaId, collect(point({latitude: toFloat(geoCoord[0]), longitude: toFloat(geoCoord[1])})) as points
MERGE (areas:Areas {wkt:points, name: areaName, type: areaType, areaId: areaId})
RETURN areas.name, areas.type, areas.areaId, areas.wkt
The above is based on previous posting: How to create nodes in nested array of JSON - #14 by ameyasoft
My understanding is that if I am to be looking for points in a poly it should be formatted like so:
create(aor99:AREAS{name:'AOR99', areaId:'c797b1ad-0933-4e4c-8876-2a77b85464a5', type:'AO', wkt:'POLYGON((-77.2905 34.7210, -77.4744 34.6875, -77.4415 34.5440, -77.2966 34.4844, -77.1752 34.5471, -77.2491 34.6722, -77.2905 34.7210))'})
But what I get is more like:
Any suggestions would be greatly appreciated.
Thanks,
Michael