geojson to json --missing multiple row output

All other Source.Python topics and issues.
nonta
Junior Member
Posts: 1
Joined: Thu Mar 03, 2022 11:53 pm

geojson to json --missing multiple row output

Postby nonta » Fri Mar 04, 2022 12:12 am

I have a geojson file zz.geojson and want to convert it to json and csv. I was trying the below for json conversion, it converts but I only get 1 row output. Can you please tell me what I am missing and also how do I convert to csv with multi output.

import json

with open('H:\pycodesfile\zz.geojson','r') as f:
d = json.load(f)


for part in d['features']:
#fName = part["properties"]
output = {"type":'FeatureCollection',
"features": [{
"type": 'Feature',
"properties": part['properties'],
"geometry": {
"type": 'Point',
"coordinates": part['geometry']['coordinates']
}
}]
}


with open('H:\pycodesfile\zz.json','w') as f_out:
json.dump(output, f_out, ensure_ascii=False, indent=4)
print(json.dumps(output))[code][/code]

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 29 guests