In [1]:
Copied!
from plateaukit import load_dataset
naha = load_dataset("plateau-47201-naha-shi-2020")
naha
from plateaukit import load_dataset
naha = load_dataset("plateau-47201-naha-shi-2020")
naha
Out[1]:
Dataset(plateau-47201-naha-shi-2020)
データの取得やプレビューについては範囲の選択と抽出を参照してください。
GeoJSON への変換¶
.to_geojson()
メソッドを使ってデータセットを GeoJSON 形式に変換できます。
In [2]:
Copied!
naha.to_geojson("/tmp/plateau-47201-naha-shi-2020.geojson", types=["bldg"])
naha.to_geojson("/tmp/plateau-47201-naha-shi-2020.geojson", types=["bldg"])
Done ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
In [3]:
Copied!
import json
from pprint import pprint
with open("/tmp/plateau-47201-naha-shi-2020.geojson", "r") as f:
data = json.load(f)
pprint(data["features"][0])
import json
from pprint import pprint
with open("/tmp/plateau-47201-naha-shi-2020.geojson", "r") as f:
data = json.load(f)
pprint(data["features"][0])
{'geometry': {'coordinates': [[[127.644351, 26.177417], [127.644335, 26.177417], [127.644335, 26.177395], [127.64435, 26.177394], [127.644351, 26.177417]]], 'type': 'Polygon'}, 'properties': {'id': 'bldg_b036eb5f-048d-4f3b-b1b7-20f89c269fe7', 'measuredHeight': None}, 'type': 'Feature'}
CityJSON への変換¶
.to_cityjson()
メソッドを使ってデータセットを CityJSON 形式に変換できます。
In [4]:
Copied!
naha.to_cityjson("/tmp/plateau-47201-naha-shi-2020.city.json", types=["bldg"])
naha.to_cityjson("/tmp/plateau-47201-naha-shi-2020.city.json", types=["bldg"])
Done ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
In [5]:
Copied!
import json
from pprint import pprint
with open("/tmp/plateau-47201-naha-shi-2020.city.json", "r") as f:
data = json.load(f)
pprint(list(data["CityObjects"].items())[0])
import json
from pprint import pprint
with open("/tmp/plateau-47201-naha-shi-2020.city.json", "r") as f:
data = json.load(f)
pprint(list(data["CityObjects"].items())[0])
{'geometry': [{'boundaries': [[[[0, 1, 2, 3]], [[0, 3, 4, 5]], [[3, 2, 6, 4]], [[2, 1, 7, 6]], [[1, 0, 5, 7]], [[5, 4, 6, 7]]]], 'lod': '1', 'type': 'Solid'}], 'type': 'Building'}