︠4fcf8fcc-e9fb-4881-a6e6-deaaff9ad941s︠ import os os.system('git clone https://github.com/openseattle/seattle-boundaries.git') import glob import json onebiggeojson = { "type": "FeatureCollection", "features": [ ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } } print glob.glob('seattle-boundaries/data/*.geojson') for filename in glob.glob('seattle-boundaries/data/*.geojson'): print filename features = [] with open(filename, 'r') as f: features = json.loads(f.read())["features"] for i, feature in enumerate(features): fntail = os.path.split(filename)[1] newproperties = {} if not "properties" in feature: newproperties["name"] = fntail[:-8] else: #newproperties["name"] = ' '.join(flatten([(item[0],str(item[1])) for item in feature["properties"].items()])) if "name" in feature["properties"]: newproperties["name"] = feature["properties"]["name"] elif "NAME" in feature["properties"]: newproperties["name"] = feature["properties"]["NAME"] elif len(feature["properties"]) == 1: newproperties["name"] = feature["properties"].items()[0][1] elif fntail == 'zip-codes.geojson': newproperties["name"] = feature["properties"]['GEOID10'] else: newproperties["name"] = ' '.join(flatten([(item[0],str(item[1])) for item in feature["properties"].items()])) if i == 0: print fntail, feature.get("properties"), newproperties #if "name" in feature["properties"]: # newproperties["name"] = feature["properties"]["name"] #else: # newproperties["name"] = ' '.join(flatten([(item[0],str(item[1])) for item in feature["properties"].items()])) newproperties["type"] = fntail[:-8] feature["properties"] = newproperties #print len(features) onebiggeojson["features"].extend(features) with open('seattle_boundaries.geojson', 'w') as f: f.write(json.dumps(onebiggeojson)) ︡46685bf0-a6bc-4833-817b-27ac68ce0ce6︡︡{"stdout":"32768\n"}︡{"stdout":"['seattle-boundaries/data/zoning.geojson', 'seattle-boundaries/data/sps_school_site_2015_2016.geojson', 'seattle-boundaries/data/city-limits.geojson', 'seattle-boundaries/data/neighborhoods.geojson', 'seattle-boundaries/data/seattle-waleg.geojson', 'seattle-boundaries/data/spd-precincts.geojson', 'seattle-boundaries/data/spd-beats.geojson', 'seattle-boundaries/data/ruv.geojson', 'seattle-boundaries/data/seattle-parks-osm.geojson', 'seattle-boundaries/data/zip-codes.geojson', 'seattle-boundaries/data/sps_attendance_area_HS.geojson', 'seattle-boundaries/data/seattle-congress.geojson', 'seattle-boundaries/data/sps_attendance_area_ES.geojson', 'seattle-boundaries/data/spd-mcpp-areas.geojson', 'seattle-boundaries/data/city-council-districts.geojson', 'seattle-boundaries/data/census-tracts.geojson', 'seattle-boundaries/data/sps_attendance_area_MS.geojson']\n"}︡{"stdout":"seattle-boundaries/data/zoning.geojson\nzoning.geojson"}︡{"stdout":" {u'EFFECTIVE': {u'month': 12, u'day': 12, u'year': 1998}, u'SYMBOL': 121, u'POLYLEN': 0, u'HISTORIC': None, u'OLDZONEID': 295, u'SHAPE_Leng': 0.000927180920409, u'MIO': None, u'SPLIT1': 0, u'CONTRACT': None, u'POLYAREA': 0, u'VILLAGE': None, u'GEO': None, u'OVERLAY': None, u'ORDINANCE': u'119218', u'ZONING': u'NC3-65', u'ZONEID': 542, u'PEDESTRIAN': None, u'ZONELUT': u'NC3', u'SHAPE_Area': 5.31650303668e-08, u'ZONELUT_DE': u'Neighborhood Commercial 3', u'SHORELINE': None, u'LIGHTRAIL': None, u'CLASS_DESC': u'Neighborhood/Commercial'} {'name': u\"EFFECTIVE {u'month': 12, u'day': 12, u'year': 1998} SYMBOL 121 POLYLEN 0 HISTORIC None OLDZONEID 295 SHAPE_Leng 0.000927180920409 MIO None SPLIT1 0 CONTRACT None POLYAREA 0 VILLAGE None GEO None OVERLAY None ORDINANCE 119218 ZONING NC3-65 ZONEID 542 PEDESTRIAN None ZONELUT NC3 SHAPE_Area 5.31650303668e-08 ZONELUT_DE Neighborhood Commercial 3 SHORELINE None LIGHTRAIL None CLASS_DESC Neighborhood/Commercial\"}\nseattle-boundaries/data/sps_school_site_2015_2016.geojson"}︡{"stdout":"\nsps_school_site_2015_2016.geojson {u'Status': u'MS', u'PROPERTY_L': u'Jane Addams'} {'name': u'Status MS PROPERTY_L Jane Addams'}\nseattle-boundaries/data/city-limits.geojson\ncity-limits.geojson"}︡{"stdout":" None {'name': 'city-limits'}\nseattle-boundaries/data/neighborhoods.geojson\nneighborhoods.geojson"}︡{"stdout":" {u'city': u'Seattle', u'name': u'Loyal Heights', u'area': 21320655.546, u'nested': u'Loyal Heights', u'county': u'King', u'nhood': u'Ballard'} {'name': u'Loyal Heights'}\nseattle-boundaries/data/seattle-waleg.geojson\nseattle-waleg.geojson {u'POPASIAN2': 30067, u'GQ10': 1119, u'SLDUST12': u'011', u'AWATERM': 3098443.0, u'STATEFP10': u'53', u'NAMELSAD10': u'State Legislative District 11', u'POPBLACK': 15773, u'COUNTYFP': u'033', u'INTPTLAT10': 47.4538236, u'MTFCC10': u'G5210', u'POPWHITE2': 64222, u'POPNHOPI2': 1320, u'OHU10': 51311, u'POPOTH': 9082, u'AWATERMI': 1.196, u'LSAD10': u'LU', u'POPOTH2': 261, u'HU10': 54740, u'POPTWO2': 6560, u'POPAIAN2': 795, u'POPTWO': 8186, u'ALANDM': 120370357.0, u'HHP10': 136159, u'ALANDMI': 46.475, u'FUNCSTAT10': u'N', u'POPNHOPI': 1384, u'POP10': 137278, u'POPASIAN': 30275, u'GEOID10': u'53011', u'POPWHITE': 71456, u'COUNTYNAME': u'King', u'GEOID102': u'53011033', u'POPBLACK2': 15365, u'POPAIAN': 1122, u'LSY10': u'2010', u'POPHISP': 18688, u'INTPTLON10': -122.1302918} {'name': u'POPASIAN2 30067 GQ10 1119 SLDUST12 011 AWATERM 3098443.0 STATEFP10 53 NAMELSAD10 State Legislative District 11 POPBLACK 15773 COUNTYFP 033 INTPTLAT10 47.4538236 MTFCC10 G5210 POPWHITE2 64222 POPNHOPI2 1320 OHU10 51311 POPOTH 9082 AWATERMI 1.196 LSAD10 LU POPOTH2 261 HU10 54740 POPTWO2 6560 POPAIAN2 795 POPTWO 8186 ALANDM 120370357.0 HHP10 136159 ALANDMI 46.475 FUNCSTAT10 N POPNHOPI 1384 POP10 137278 POPASIAN 30275 GEOID10 53011 POPWHITE 71456 COUNTYNAME King GEOID102 53011033 POPBLACK2 15365 POPAIAN 1122 LSY10 2010 POPHISP 18688 INTPTLON10 -122.1302918'}\nseattle-boundaries/data/spd-precincts.geojson\nspd-precincts.geojson {u'name': u'E'} {'name': u'E'}\nseattle-boundaries/data/spd-beats.geojson\nspd-beats.geojson"}︡{"stdout":" {u'name': u'B1'} {'name': u'B1'}\nseattle-boundaries/data/ruv.geojson\nruv.geojson {u'Residential Urban Village': u'23rd and Union-Jackson'} {'name': u'23rd and Union-Jackson'}\nseattle-boundaries/data/seattle-parks-osm.geojson\nseattle-parks-osm.geojson {u'tags': u'\"website\"=>\"http://www.seattle.gov/parks/park_detail.asp?ID=80\"', u'name': u'Charles Richey Sr Viewpoint', u'osm_id': 50723129.0} {'name': u'Charles Richey Sr Viewpoint'}\nseattle-boundaries/data/zip-codes.geojson\nzip-codes.geojson {u'AWATER10': 2163632.0, u'AFFGEOID10': u'8600000US98136', u'GEOID10': u'98136', u'ALAND10': 5954030.0, u'ZCTA5CE10': u'98136'} {'name': u'98136'}\nseattle-boundaries/data/sps_attendance_area_HS.geojson\nsps_attendance_area_HS.geojson"}︡{"stdout":" {u'HS_ZONE': u'Ballard'} {'name': u'Ballard'}\nseattle-boundaries/data/seattle-congress.geojson\nseattle-congress.geojson {u'LSAD': u'C2', u'AWATER': 340666726.0, u'CD114FP': u'07', u'CDSESSN': u'114', u'AFFGEOID': u'5001400US5307', u'GEOID': u'5307', u'STATEFP': u'53', u'ALAND': 373031843.0} {'name': u'LSAD C2 AWATER 340666726.0 CD114FP 07 CDSESSN 114 AFFGEOID 5001400US5307 GEOID 5307 STATEFP 53 ALAND 373031843.0'}\nseattle-boundaries/data/sps_attendance_area_ES.geojson\nsps_attendance_area_ES.geojson {u'ES_ZONE': u'Adams'} {'name': u'Adams'}\nseattle-boundaries/data/spd-mcpp-areas.geojson\nspd-mcpp-areas.geojson {u'PRECINCT': u'SW', u'NAME': u'ALASKA JUNCTION'} {'name': u'ALASKA JUNCTION'}\nseattle-boundaries/data/city-council-districts.geojson\ncity-council-districts.geojson"}︡{"stdout":" {u'district': 1} {'name': 1}\nseattle-boundaries/data/census-tracts.geojson\ncensus-tracts.geojson {u'geoid': u'14000US53033000100', u'name': u'Census Tract 1, King, WA'} {'name': u'Census Tract 1, King, WA'}\nseattle-boundaries/data/sps_attendance_area_MS.geojson\nsps_attendance_area_MS.geojson {u'MS_ZONE': u\"Denny Int'l\"} {'name': u\"Denny Int'l\"}\n"}︡{"done":true} ︠f91c5d78-f2e5-4c00-b311-6ba946adffba︠