Created
December 19, 2022 18:04
-
-
Save hatobus/8e4c6e4a739a583cab94b69878808613 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 | |
latitude = 0 | |
longitude = 0 | |
pref_name = "福島県" | |
with open('prefectures.geojson') as f: | |
j = json.load(f) | |
for feature in j["features"]: | |
if feature["properties"]["name"] == pref_name: | |
coordinates = feature["geometry"]["coordinates"] | |
points = [p for i in coordinates for j in i for p in j] | |
break | |
for p in points: | |
latitude = latitude + p[1] | |
longitude = longitude + p[0] | |
print("{}, {}".format(latitude/len(points), longitude/len(points))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment