データフレーム¶
データは表形式 (pandas.DataFrame
/ geopandas.GeoDataFrame
) で処理することができます。
In [1]:
Copied!
from plateaukit import load_dataset
# データの読み込み
dataset = load_dataset("plateau-08220-tsukuba-shi-2022")
# 郵便番号から範囲を取得
area = dataset.area_from_landmark("つくば駅")
# データを表示
area.gdf
from plateaukit import load_dataset
# データの読み込み
dataset = load_dataset("plateau-08220-tsukuba-shi-2022")
# 郵便番号から範囲を取得
area = dataset.area_from_landmark("つくば駅")
# データを表示
area.gdf
Out[1]:
buildingId | measuredHeight | storeysAboveGround | name | usage | type | geometry | longitude | latitude | |
---|---|---|---|---|---|---|---|---|---|
6337 | 08220-bldg-1874 | 3.0 | NaN | None | None | Building | POLYGON ((140.11013 36.08077, 140.11012 36.080... | 140.110104 | 36.080772 |
6338 | 08220-bldg-1862 | 3.0 | NaN | None | 商業施設 | Building | POLYGON ((140.11025 36.08109, 140.11023 36.081... | 140.110193 | 36.081079 |
6340 | 08220-bldg-1837 | 3.0 | NaN | None | 共同住宅 | Building | POLYGON ((140.10864 36.08202, 140.10863 36.082... | 140.108592 | 36.082015 |
6342 | 08220-bldg-1808 | 4.8 | NaN | None | 運輸倉庫施設 | Building | POLYGON ((140.11241 36.08268, 140.11241 36.082... | 140.112381 | 36.082373 |
6343 | 08220-bldg-1885 | 35.6 | 11.0 | None | 共同住宅 | Building | POLYGON ((140.11089 36.07988, 140.11089 36.079... | 140.110826 | 36.079876 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
11909 | 08220-bldg-86856 | 11.6 | 4.0 | None | 共同住宅 | Building | POLYGON ((140.11725 36.08675, 140.11744 36.086... | 140.117316 | 36.086839 |
11928 | 08220-bldg-86340 | NaN | NaN | None | 文教厚生施設 | Building | POLYGON ((140.11724 36.08749, 140.11734 36.087... | 140.117285 | 36.087524 |
11946 | 08220-bldg-86094 | NaN | NaN | None | 文教厚生施設 | Building | POLYGON ((140.11724 36.08776, 140.11725 36.087... | 140.117259 | 36.087752 |
11948 | 08220-bldg-87756 | 11.5 | 4.0 | None | 共同住宅 | Building | POLYGON ((140.11799 36.08609, 140.11780 36.086... | 140.117926 | 36.086002 |
11963 | 08220-bldg-85853 | 8.9 | NaN | None | 住宅 | Building | POLYGON ((140.11793 36.08788, 140.11790 36.087... | 140.117886 | 36.087875 |
603 rows × 9 columns
In [2]:
Copied!
# 3D都市モデルとして表示
area.show()
# 3D都市モデルとして表示
area.show()
Out[2]:
集計・グラフとして可視化¶
In [3]:
Copied!
## 建物の用途情報ごとに集計
usage_counts = area.gdf["usage"].fillna("未分類").value_counts()
usage_counts
## 建物の用途情報ごとに集計
usage_counts = area.gdf["usage"].fillna("未分類").value_counts()
usage_counts
Out[3]:
usage 未分類 342 共同住宅 125 文教厚生施設 58 住宅 33 運輸倉庫施設 17 業務施設 10 商業施設 7 その他 4 工場 3 宿泊施設 3 官公庁施設 1 Name: count, dtype: int64
In [4]:
Copied!
from IPython.display import HTML
import plotly.express as px
fig = px.bar(
x=usage_counts.index,
y=usage_counts.values,
labels={"x": "種類", "y": "件数"},
color=usage_counts.index,
)
fig.update_layout(showlegend=False)
# HTML(fig.to_html())
fig
from IPython.display import HTML
import plotly.express as px
fig = px.bar(
x=usage_counts.index,
y=usage_counts.values,
labels={"x": "種類", "y": "件数"},
color=usage_counts.index,
)
fig.update_layout(showlegend=False)
# HTML(fig.to_html())
fig