Created
July 16, 2023 02:43
-
-
Save ito4303/251cb5a90acb7f2eb38c96308ef6fc29 to your computer and use it in GitHub Desktop.
draw Sapporo city map using the tmap package
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
library(sf) | |
library(tmap) | |
# 参考にしたところ | |
# https://qiita.com/ocean_f/items/700aff67f3e35266b0fe | |
# 国土数値情報からデータをダウンロード | |
# https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N03-v3_1.html | |
datafile <- file.path("data", "N03-20230101_01_GML", | |
"N03-23_01_230101.geojson") | |
hokkaido <- st_read(datafile) |> | |
st_transform(crs = 6680) # JGD2011平面直角座標系XII | |
sapporo_ku <- c("中央区", "北区", "東区", "白石区", "豊平区", | |
"南区", "西区", "厚別区", "手稲区", "清田区") | |
sapporo <- hokkaido |> | |
dplyr::filter(N03_003 == "札幌市") |> | |
dplyr::mutate(`区` = factor(substring(N03_004, 4), | |
levels = sapporo_ku)) | |
tm_shape(sapporo) + | |
tm_polygons("区", legend.show = FALSE) + | |
tm_text("区", size = 0.7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment