# This file is designed to convert tree data from a # csv format (at opentrees.org) to a geojson format. # This version uses compact versions of the standard geojson keys, # to make transferring over the network more efficient. # # This effort is part of the earthtree ios swift app which is # designed to display and map trees in the entire world! one by one! # # import csv with open('opentrees.data.csv', mode='r') as f: reader = csv.DictReader(f) s = """ { "type": "FeatureCollection", "features": [ """ print s for row in reader: s = """ {{ "type": "Feature", "geom": {{ "type": "Point", "coords": [{lat}, {lon}] }}, "props": {{ "genus": "{genus}" "sp: "{species}" "var": "{variety}" "desc": "{description}" "common": "{common}" "height": "{height}" "crown": "{crown}" "dbh": "{dbh}" "health": "{health}" "struc": "{structure}" "src": "{source}" }} }}""".format(**row) print s print " ] } " ## id,geom,tree_type,genus,species,scientific,variety,description,common,height,crown,dbh,health,structure,captured,planted,ule_min,ule_max,ref,location,maturity,lat,lon,source,s