Hi,
I have a geoJSON newline-delimited data file. It was created from QGIS, an OSM file with a height attribute in it. I want to parse that in Dynamo, create the polylines from the " geometry[coordinates] " column of the file to create buildings footprints, and extrude each building footprint by creating polycurve and extruding them according to the data in the “heights_max” column".
the file is like this: (data string):
{ “type”: “Feature”, “properties”: { “full_id”: “w1097381425”, “osm_id”: “1097381425”, “osm_uid”: “8150490”, “building”: null, “Heights_mean”: -3.8323120390415735, “Heights_min”: -6.0, “Heights_max”: 12 }, “geometry”: { “type”: “Polygon”, “coordinates”: [ [ [ 29.1476383, 40.8478408 ], [ 29.1476134, 40.8477578 ], [ 29.1476489, 40.8477517 ], [ 29.1476738, 40.8478347 ], [ 29.1476383, 40.8478408 ] ] ] } }
so I have searched how to parse geoJSON file and try to parse the file like this.
import json
data = json.loads(datastring)
data['geometry']["coordinates"]
so I tried writing this in Python script that works with a string input where I copied and pasted the contents of the geoJSON file
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import json
# The inputs to this node will be stored as a list in the IN variables.
Text=IN[0]
# Place your code below this line
data = json.loads(Text)
# Assign your output to the OUT variable.
OUT =data["geometry"]["coordinates"]
but I couldn’t parse it. Could you help me to parse them?
ps: it is also said in the StackOverflow forum that using geopandas package may be better but I guess installing that package in Dynamo would be much harder way to parse it.
I tried using dataJSON package in dynamo.
I tried reading file like csv but get too many columns by that way.
Should I import the geoJSON file in Excel and convert it to CSV?
parsejson2.dyn (50.2 KB)