In [72]:
import pandas as pd
import numpy as np
import json, re
In [109]:
df = pd.read_csv("all.tsv")
In [114]:
df['unique_id'] = df.DRS_ID.map(str) + "_" + df.MAP
In [116]:
df.loc[df.unique_id.isnull(),'unique_id'] = df.DRS_ID
In [118]:
lookup = json.loads(df.set_index('unique_id').to_json(orient='index'))
In [119]:
with open("geoJson/all_atlases.geojson","r") as fp:
gj = json.load(fp)
In [120]:
features = gj['features']
In [123]:
lookup['42668961']
Out[123]:
In [129]:
for f in features:
uid = str(re.findall(r"[0-9]{8}(?:_MAP[ABCD])?",f['properties']['fname'])[0])
f['properties']['UNIQUE_ID']=uid
to_add = lookup[uid]
f['properties'].update(to_add)
In [132]:
gj['features'] = features
In [135]:
with open("geoJson/all_atlases.geojson","w") as fp:
json.dump(gj,fp,indent=2,sort_keys=True)