Last active
July 10, 2019 14:54
-
-
Save NbtKmy/66dfd22a4c7225e854f0a5671564e765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def main(): | |
f = open("/path/to/your.geojson", 'r') | |
json_data = json.load(f) | |
for i in range(len(json_data["features"])): | |
lat2 = json_data["features"][i]["properties"]["lat2"] | |
lon2 = json_data["features"][i]["properties"]["lon2"] | |
if(lat2 is not None): | |
geo_type = json_data["features"][i]["geometry"]["type"] | |
geo_type2 = geo_type.replace("Point", "LineString") | |
json_data["features"][i]["geometry"]["type"] = geo_type2 | |
cord = json_data["features"][i]["geometry"]["coordinates"] | |
geo_data = [lon2, lat2] | |
json_data["features"][i]["geometry"]["coordinates"] = [cord, geo_data] | |
f = open("path/to/your.geojson", 'w') | |
json.dump(json_data, f, ensure_ascii=False, indent=4) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
人間文化研究機構の歴史地名辞書データ(CSVファイル)をQGISを使ってGeoJson形式に変更した。ここにあげたファイルにより緯度経度が2つあるものに関してはジオメトリのタイプを「LineString」に変更し、かつ2つ目の緯度経度をジオメトリの「coordinates」に挿入するようにした。