I have a geoJSON file, which contains a breakdown of a certain geographical area into ca. 7000 cells. I'd like to a) open this geoJSON b) modify some data (see code bellow) and c) write this modified geoJSON to the disk. Now, my problem is, that since there's a lot of cells, this takes almost a minute. Do you see any way to improve the speed of this function? Thank you!
def writeGeoJSON(param1, param2, inputdf):
with open('ingeo.geojson') as f:
data = json.load(f)
for feature in data['features']:
currentfeature = inputdf[(inputdf['SId']==feature['properties']['cellId']) & (inputdf['param1']==param1) & (inputdf['param2']==param2)]
if (len(currentfeature) > 0):
feature['properties'].update({"style": {"opacity": currentfeature.Opacity.item()}})
else:
feature['properties'].update({"style": {"opacity": 0}})
end = time.time()
with open('outgeo.geojson', 'w') as outfile:
json.dump(data, outfile)