Append geoJSON feature with Python? -


i have following structure in geojsonfile:

{"crs":    {"type": "name",     "properties":       {"name": "urn:ogc:def:crs:epsg::4326"}   },     "type": "featurecollection",     "features": [      {"geometry":         {"type": "polygon",          "coordinates": [[[10.914622377957983, 45.682007076150505],                          [10.927456267537572, 45.68179119797432],                           [10.927147329501077, 45.672795442796335],                          [10.914315493899755, 45.67301125363092],                           [10.914622377957983, 45.682007076150505]]]},                    "type": "feature",          "id": 0,          "properties": {"cellid": 38}    },       {"geometry":          {"type": "polygon",           "coordinates":    ... etc. ... 

i want read geojson google maps , have each cell colored based on property calculated in python each cell individually. question be: how can read geojson in python , add property these polygons (there 12 000 polygons, adding them 1 one not option), write new file?

i think i'm looking library python can handle geojson, don't have add these feature via srting manipulation.

the geojson json doc (a simplification need purpose). python reads dict object.

since dict updated inplace, don't need store new variable geo objects.

import json  # read in json  geo_objects = json.load(open("/path/to/files"))  # code ...  d in geo_objects:     d["path"]["to"]["field"] = calculated_value  json.dump(geofiles, open("/path/to/output/file")) 

no string manipulation needed, no need load new library!


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -