Introduction

Hi! My name is YAMAGUCHI Yuhei. I am a M2 student at Tohoku University, Sendai, Japan. I am interested in satellite remote sensing and its application to social science. This is just practice of RPubs.

In this document, I show the cultivation situation of paddy fields in Mogami, Yamagata Pref. predicted by data from SAR satellite (Sentinel-1) and optical satellite (Sentinel-2) with DNN.
I do not introduce the detail of DNN model, but I just show you the result of prediction.

Packages

Data

read data of predicted situation of paddies.

df <- read.csv("yamagata_2024_paddy_condition.csv") %>% 
  dplyr::select(id, predicted)
df %>% glimpse()
## Rows: 569,307
## Columns: 2
## $ id        <chr> "0410-143823-025591", "0610-098740-082164", "0610-098742-082…
## $ predicted <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …

read data of Fude Polygon. shape file of rice paddies and fields.

fude <- read_sf("06362最上町(2021公開)/06362最上町(2021公開)_5.shp",
                options = "ENCODING=CP932") %>% 
  filter(
    耕地の種類 == "田"
  ) %>% 
  mutate(
    area = as.numeric(st_area(geometry)) # 面積を計算
  )

merge data

fude_condition <- left_join(
  fude, df, by = "id"
)
fude_condition %>% glimpse()
## Rows: 13,346
## Columns: 7
## $ id         <chr> "0410-143823-025591", "0610-132008-027593", "0610-132025-02…
## $ 公開年度   <int> 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021,…
## $ 調製年度   <int> 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020,…
## $ 耕地の種類 <chr> "田", "田", "田", "田", "田", "田", "田", "田", "田", "田",…
## $ geometry   <POLYGON [m]> POLYGON ((-25598.29 -143808..., POLYGON ((-27627.99…
## $ area       <dbl> 452.82580, 1734.67524, 1093.71726, 340.22553, 297.70464, 22…
## $ predicted  <int> 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, NA, 1, 0, 0…
# 変数の調整
fude_condition <- fude_condition %>% 
  mutate(
    predicted = as.factor(predicted)
  )

plot with mapview

fude_condition %>% 
  # exclude NA
  filter(
    is.na(predicted) == F
  ) %>% 
  # limit variables
  dplyr::select(
    id, area, predicted
  ) %>% 
  # plot 
  mapview(zcol = "predicted",
          col.regions = c("tomato", "turquoise"),
          color="white", lwd = .1, 
          map.types="Esri.WorldImagery")

Appendix

Relation between area [m^2] and paddies’ situation is followiog.

fude_condition %>% 
    filter(
    is.na(predicted) == F
  ) %>% 
  ggplot() +
  stat_halfeye(
    aes(x = area, y = predicted,
        fill = as.factor(predicted)),
    alpha = .75
  ) +
    geom_boxplot(
    aes(x = area, y = predicted,
        fill = as.factor(predicted)),
    position = position_nudge(y = -.1),
    width = .1,
    outlier.colour = NA,
    alpha = .5
  ) +
  geom_point(
    aes(x = area, y = predicted),
    color = "black",
    position = position_jitter(width = 0, height = 0.025, seed = 1),
    alpha = .01
  ) +
  scale_fill_manual(
    values = c("salmon", "turquoise3")
  ) +
  labs(x = "area [m^2]", y = "predicted situation of paddies") +
  theme_minimal() +
  theme(legend.position = "none")