Guest User

Parks Python

a guest
Nov 24th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import json
  2. import csv
  3. soubor = open('prirodni_parky.json', encoding='utf-8')
  4. data = soubor.read()
  5. parks = json.loads(data)
  6. writer = csv.writer(open("natural_parks.csv", 'w', newline='', encoding='utf-8'))
  7. writer.writerow(['objectid','name','shapelength','shapearea','latitude','longitude'])
  8. for p in parks['features']:
  9.   objectid = p['properties']['OBJECTID']
  10.   name = p['properties']['NAZEV']
  11.   shapelength = p['properties']['Shape_Length']
  12.   shapearea = p['properties']['Shape_Area']
  13.   souradnice = p['geometry']['coordinates'][0]
  14.   for s in souradnice:
  15.     latitude = s[1]
  16.     longitude = s[0]
  17.     writer.writerow([objectid,name,shapelength,shapearea,latitude,longitude])
Add Comment
Please, Sign In to add comment