範囲の選択と抽出¶
PLATEAUデータの読み込みについてはデータセットの読み込みと利用を参照してください。
In [1]:
Copied!
from plateaukit import load_dataset
# データの読み込み
tokyo23ku = load_dataset("plateau-tokyo23ku-2022")
from plateaukit import load_dataset
# データの読み込み
tokyo23ku = load_dataset("plateau-tokyo23ku-2022")
範囲の選択¶
読み込んだデータセットから範囲を取得するには、いくつかの方法が利用可能です。
get_area()
: 全範囲を選択します。area_from_bbox(bbox)
: 範囲を[左上のx座標 (経度), 左上のy座標 (緯度), 右下のx座標 (経度), 右下のy座標 (緯度)]
で指定します。area_from_points(point, size=[width, height])
: 範囲を一つ以上の地点の座標と範囲のサイズで指定します。area_from_postcode(postcode)
: 範囲を郵便番号で指定します。area_from_address(address)
: 範囲を住所で指定します。area_from_landmark(landmark)
: 範囲を建物等のランドマークの名前から指定します。
In [2]:
Copied!
# 住所から範囲を取得
area = tokyo23ku.area_from_address("東京都新宿区西新宿2-8-1")
area
# 住所から範囲を取得
area = tokyo23ku.area_from_address("東京都新宿区西新宿2-8-1")
area
Out[2]:
Area()
In [3]:
Copied!
area.show()
area.show()
Out[3]:
選択範囲のデータを取得¶
.gdf
プロパティから選択範囲のデータ (geopandas.GeoDataFrame
) を取得できます。
In [4]:
Copied!
area.gdf
area.gdf
Out[4]:
buildingId | measuredHeight | name | type | longitude | latitude | geometry | |
---|---|---|---|---|---|---|---|
19070 | 13104-bldg-7859 | 11.6 | None | Building | 139.687497 | 35.691507 | POLYGON ((139.68748 35.69145, 139.68756 35.691... |
19072 | 13104-bldg-7845 | 17.1 | None | Building | 139.687385 | 35.691473 | POLYGON ((139.68739 35.69144, 139.68746 35.691... |
19073 | 13104-bldg-7963 | 21.6 | None | Building | 139.687371 | 35.691601 | POLYGON ((139.68741 35.69155, 139.68745 35.691... |
19226 | 13104-bldg-6456 | 7.6 | None | Building | 139.687297 | 35.690204 | POLYGON ((139.68736 35.69020, 139.68732 35.690... |
19368 | 13104-bldg-4642 | 9.5 | None | Building | 139.687259 | 35.688730 | POLYGON ((139.68732 35.68871, 139.68730 35.688... |
... | ... | ... | ... | ... | ... | ... | ... |
56483 | 13104-bldg-11151 | 32.1 | None | Building | 139.692667 | 35.694708 | POLYGON ((139.69274 35.69477, 139.69268 35.694... |
56484 | 13104-bldg-8242 | 3.0 | None | Building | 139.687557 | 35.691978 | POLYGON ((139.68757 35.69202, 139.68754 35.692... |
56494 | 13104-bldg-10881 | 13.3 | None | Building | 139.693556 | 35.694538 | POLYGON ((139.69351 35.69447, 139.69357 35.694... |
56496 | 13104-bldg-9998 | 4.2 | None | Building | 139.696075 | 35.693910 | POLYGON ((139.69605 35.69393, 139.69604 35.693... |
56499 | 13104-bldg-10498 | 133.3 | 関東信越厚生局東京事務所 | Building | 139.687721 | 35.694073 | POLYGON ((139.68792 35.69406, 139.68796 35.694... |
984 rows × 7 columns
GeoJSON への変換¶
.to_geojson()
メソッドを使って選択範囲を GeoJSON 形式に変換できます。
In [5]:
Copied!
data = area.to_geojson()
data[:300]
data = area.to_geojson()
data[:300]
Out[5]:
'{"type": "FeatureCollection", "features": [{"id": "19070", "type": "Feature", "properties": {"buildingId": "13104-bldg-7859", "measuredHeight": 11.6, "name": null, "type": "Building", "longitude": 139.6874967006076, "latitude": 35.69150682752363}, "geometry": {"type": "Polygon", "coordinates": [[[13'