選挙マップを提供する大きな geoJSON ファイルがあります。私はサイトをスクレイピングし、有権者選挙区の結果を次のような Python 辞書に返しました{u'605': [u'56', u'31'], u'602': [u'43', u'77']
:
辞書の結果を使用して、geoJSON ファイル (すべての有権者地区) を更新したいと考えています。私の geoJSON ファイルには、キーと値のペア ( - など"precNum": 602
) の 1 つとして地区番号があります。ディクショナリの結果で各形状を更新するにはどうすればよいですか?
次のようなものを使用して、geoJSON ファイルをターゲットにしてループできます。
for precincts in map_data["features"]:
placeVariable = precincts["properties"]
placeVariable["precNum"]
#This gives me the precinct number of the current shape I am in.
placeVariable["cand1"] = ??
# I want to add the Value of first candidate's vote here
placevariable["cand2"] = ??
# I want to add the Value of second candidate's vote here
どんなアイデアでも大きな助けになるでしょう。