令和6年元旦に能登半島で大きな地震がありました.私は能登半島の出身で,そこに実家があるため帰省していました.揺れはとても大きく,街中がぐちゃぐちゃになってしまいました.当然,これだけ大きな被害があると,さまざまな産業に影響が出ると考えられます.農業も例外ではないでしょう.農具が破損したり,農業の担い手が減少したりした地域があると考えられます.
この記事では,能登半島の農業集落ごとの水田耕作枚数に注目し,震災前後でそれがどのように増減したかを推定します.
なおこの記事で使用したデータは現在公開しておりません.Sentinel-1とSentinel-2によるリモートセンシングを行い,そのデータを用いてDNNで水田利用状況を推定したものです.もうちょっとしたら公開するかもしれません.
library(tidyverse) # データハンドリングの効率化
library(sf) # 空間データのハンドリング
library(patchwork) # 複数の図を簡単に並べる
library(agribbit) # 農林業センサスデータを取得
library(ggdist)
library(mapview) # 動かせる地図
predictedという名前が入っている変数は,それぞれの年の水田耕作枚数の予測値.使うのは2021-2024年のデータ.
noto <- read_csv("noto_num_pad_cul.csv") %>%
dplyr::select(-...1) # 不要な列を削除
noto %>% glimpse()
## Rows: 806
## Columns: 8
## $ KEY_CODE <dbl> 1720201001, 1720201002, 1720201004, 1720201005, 17202010…
## $ predicted2017 <dbl> 119, 1, 15, 18, 25, 105, 56, 31, 274, 95, 247, 103, 302,…
## $ predicted2018 <dbl> 146, 1, 19, 23, 39, 112, 56, 29, 268, 91, 264, 114, 302,…
## $ predicted2020 <dbl> 115, 2, 17, 24, 29, 101, 54, 28, 267, 97, 249, 103, 320,…
## $ predicted2021 <dbl> 117, 1, 16, 17, 28, 89, 54, 32, 268, 92, 257, 103, 303, …
## $ predicted2022 <dbl> 120, 0, 18, 17, 36, 105, 58, 28, 283, 88, 254, 109, 299,…
## $ predicted2023 <dbl> 99, 1, 15, 14, 25, 88, 57, 30, 253, 96, 245, 100, 261, 2…
## $ predicted2024 <dbl> 69, 1, 12, 16, 30, 84, 55, 29, 250, 95, 235, 106, 278, 2…
とりあえず描画.{agribbit}で石川県の農林業センサスの.shpを拾います.それを先ほど読み込んだデータと結合して地図にしましょう.agribbit::agri_read_census_shp()の引数に都道府県コード(石川県なら17)を指定すれば取得できます.
ishikawa_shp <- agri.read_census_shp(17) %>%
mutate(KEY_CODE = KEY_CODE)
データを読み込んだら,まずは適当に描画してみるのが鉄の掟,いや,ダイヤモンドの掟です.自分がRを初めて習ったとき(学部2年の冬),その講義の先生がそういう旨のことをおっしゃっていた気がします.
2021年から2024年までの耕作枚数の図のオブジェクトを作成して,それを{patchwork}で並べて表示してみます.
# それぞれの年の図のオブジェクトを作成していく
noto_2021 <- left_join(noto, ishikawa_shp, by = "KEY_CODE") %>%
st_as_sf() %>%
ggplot() +
geom_sf(
aes(fill = predicted2021),
lwd = .1
) +
scale_fill_fermenter(
name = "",
breaks = seq(0, 700, 100),
direction = 1,
palette = "YlGnBu"
) +
labs(fill = "", x = "2021") +
theme_minimal() +
theme(
legend.position = "none",
axis.text = element_blank(),
axis.ticks = element_blank()
)
noto_2022 <- left_join(noto, ishikawa_shp, by = "KEY_CODE") %>%
st_as_sf() %>%
ggplot() +
geom_sf(
aes(fill = predicted2022),
lwd = .1
) +
scale_fill_fermenter(
name = "",
breaks = seq(0, 700, 100),
direction = 1,
palette = "YlGnBu"
) +
labs(fill = "", x = "2022") +
theme_minimal() +
theme(
legend.position = "none",
axis.text = element_blank(),
axis.ticks = element_blank())
noto_2023 <- left_join(noto, ishikawa_shp, by = "KEY_CODE") %>%
st_as_sf() %>%
ggplot() +
geom_sf(
aes(fill = predicted2023),
lwd = .1
) +
scale_fill_fermenter(
name = "",
breaks = seq(0, 700, 100),
direction = 1,
palette = "YlGnBu"
) +
labs(fill = "", x = "2023") +
theme_minimal() +
theme(
legend.position = "top",
legend.key.width = unit(2, "cm"),
axis.text = element_blank(),
axis.ticks = element_blank())
noto_2024 <- left_join(noto, ishikawa_shp, by = "KEY_CODE") %>%
st_as_sf() %>%
ggplot() +
geom_sf(
aes(fill = predicted2024),
lwd = .1
) +
scale_fill_fermenter(
name = "",
breaks = seq(0, 700, 100),
direction = 1,
palette = "YlGnBu"
) +
labs(fill = "", x = "2024") +
theme_minimal() +
theme(
legend.position = "none",
axis.text = element_blank(),
axis.ticks = element_blank())
# 並べる
noto_2021_2024 <- noto_2021 + noto_2022 + noto_2023 + noto_2024 + plot_layout(nrow = 1)
noto_2021_2024
2024年の水田耕作枚数の地図をインタラクティブに描画してみましょう.任意の場所をクリックすると,その地域の水田耕作枚数を見ることができます.ここで表示される水田耕作枚数は実測値ではなく,あくまでも予測値出ることに注意してください.また,衛星の分解能の問題で小さい水田は正しく観測されていません.そのため.小さい水田は,実際には耕作されていても非耕作水田として分類されている場合があります.この問題を解決するには,より分解能の良い衛星を使うほかありません.分解能の優れた衛星は高額であること,さらに,そのようなデータを持っていてもスピーディに処理できる計算機を有していないことなどの難点がありますがねえ.
noto %>%
left_join(., ishikawa_shp) %>%
st_as_sf() %>%
dplyr::select(predicted2024) %>%
mapview(
zcol = "predicted2024"
)
## Joining with `by = join_by(KEY_CODE)`
山形県はDIDにおける統制群として扱う.こちらも2021-2024までのデータしか使わない.
yamagata <- noto_abandoned_df <- read_csv("yamagata_num_pad_cul.csv") %>%
mutate(
KEY_CODE = as.numeric(KEY_CODE)
) %>%
dplyr::select(-...1)
## New names:
## Rows: 2582 Columns: 7
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," dbl
## (7): ...1, KEY_CODE, predicted2019, predicted2021, predicted2022, predic...
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
yamagata %>% glimpse()
## Rows: 2,582
## Columns: 6
## $ KEY_CODE <dbl> 620101001, 620101002, 620101003, 620101004, 620101009, 6…
## $ predicted2019 <dbl> 122, 94, 0, 0, 571, 2, 2, 0, 0, 84, 4, 0, 0, 53, 474, 18…
## $ predicted2021 <dbl> 124, 98, 0, 0, 646, 3, 1, 0, 0, 92, 10, 0, 0, 57, 542, 1…
## $ predicted2022 <dbl> 121, 95, 0, 0, 624, 2, 1, 0, 1, 77, 8, 0, 0, 36, 491, 15…
## $ predicted2023 <dbl> 123, 96, 1, 0, 606, 5, 0, 0, 0, 65, 1, 0, 1, 54, 504, 20…
## $ predicted2024 <dbl> 124, 97, 1, 0, 633, 1, 1, 0, 0, 76, 12, 0, 1, 55, 508, 1…
山形も2024年だけ簡単に描画してみるとする.
yamagata_shp <- agri.read_census_shp(6)
yamagata_shp %>%
left_join(., yamagata) %>%
dplyr::select(predicted2024) %>%
mapview(
zcol = "predicted2024"
)
## Joining with `by = join_by(KEY_CODE)`