Skip to contents

Structure of combined Fude Polygon data with agricultural community boundary data

library(fude)

d <- read_fude("~/2022_38.zip", quiet = TRUE, supplementary = TRUE)
b <- get_boundary(d, path = "~/ma", quiet = TRUE)

d2 <- read_fude("~/MB0001_2026_2025_38.zip.001", quiet = TRUE)

GeoJSON data characteristics (obtain data #1)

library(sf)

db <- d |>
  lapply(st_transform, crs = 4612) |>
  combine_fude(b, city = "松山市", rcom = "由良|北浦|鷲ケ巣|門田|馬磯|泊|御手洗|船越")

There are 7 types of objects obtained by combine_fude(), as follows:

names(db)
## [1] "fude"       "fude_split" "rcom"       "rcom_union" "kcity"     
## [6] "city"       "pref"
library(ggplot2)

ggplot() +
  geom_sf(data = db$fude, aes(fill = rcom_romaji), alpha = .8) +
  guides(fill = guide_legend(reverse = TRUE, title = "Agricultural community")) +
  theme_void() +
  theme(legend.position = "bottom") +
  theme(text = element_text(family = "Hiragino Sans"))

Source: Adapted from “Fude Polygon Data (released in FY 2022)” and “Agricultural Community Boundary Data (FY 2025)”, published by the Ministry of Agriculture, Forestry and Fisheries.

Data assignment

  • db$fude: Automatically assigns polygons on the boundaries to a community.
  • db$fude_split: Provides cleaner boundaries, but polygon data near community borders may be divided.
library(patchwork)

fude <- ggplot() +
  geom_sf(data = db$fude, aes(fill = rcom_romaji), alpha = .8) +
  theme_void() +
  theme(legend.position = "none") +
  coord_sf(xlim = c(132.658, 132.678), ylim = c(33.887, 33.902))

fude_split <- ggplot() +
  geom_sf(data = db$fude_split, aes(fill = rcom_romaji), alpha = .8) +
  theme_void() +
  theme(legend.position = "none") +
  coord_sf(xlim = c(132.658, 132.678), ylim = c(33.887, 33.902))

fude + fude_split

Source: Adapted from “Fude Polygon Data (released in FY 2022)” and “Agricultural Community Boundary Data (FY 2025)”, published by the Ministry of Agriculture, Forestry and Fisheries.

If you need to adjust this automatic assignment, you will need to write custom code. The rows that require attention can be identified with the following command.

library(dplyr)

db$fude |>
  filter(polygon_uuid %in% (db$fude_split |> filter(duplicated(polygon_uuid)) |> pull(polygon_uuid))) |>
  st_drop_geometry() |>
  select(polygon_uuid, kcity_name, rcom_name, rcom_romaji) |>
  head()
## # A tibble: 6 × 4
##   polygon_uuid                         kcity_name rcom_name rcom_romaji
##   <chr>                                <fct>      <fct>     <fct>      
## 1 8085bc47-9af5-440f-89e9-f188d3b95746 興居島村   船越      Funakoshi  
## 2 26920da0-b63e-4994-a9eb-175e2982fe21 興居島村   馬磯      Umaiso     
## 3 ac2e7293-6c2f-4feb-a95f-4729dc8d0aec 興居島村   由良      Yura       
## 4 ea130038-7035-4cf3-b71c-091783090d74 興居島村   鷲ケ巣    Washigasu  
## 5 4aba8229-1b14-4eab-8a91-e10d9e841180 興居島村   船越      Funakoshi  
## 6 156a3459-25cb-494c-824f-9ba6b0fb6f23 興居島村   由良      Yura

FlatGeobuf data characteristics (obtain data #2)

The FlatGeobuf format offers a more efficient alternative to GeoJSON. A notable feature of this format is that each record already includes an accurately assigned agricultural community code.

db <- combine_fude(d2, b, city = "松山市", rcom = "由良|北浦|鷲ケ巣|門田|馬磯|泊|御手洗|船越")

ggplot() +
  geom_sf(data = db$fude, aes(fill = rcom_romaji), alpha = .8) +
  guides(fill = guide_legend(reverse = TRUE, title = "Agricultural community")) +
  theme_void() +
  theme(legend.position = "bottom") +
  theme(text = element_text(family = "Hiragino Sans"))

Source: Adapted from “Fude Polygon Data (released in FY 2026)” and “Agricultural Community Boundary Data (FY 2025)”, published by the Ministry of Agriculture, Forestry and Fisheries.

Possible values for rcom in combine_fude() and extract_boundary()

boundary_tree(b, max_lines = 20)
## Agricultural community boundaries (rcom_year = 2025, boundary_data_year = 2025)
## └─ 愛媛県 [38] Ehime / 20
##     ├─ 松山市 [38201] Matsuyama / 24
##     │   ├─ 松山市 [3820101] / 108
##     │   │   ├─ 土居田 [3820101001] Doida
##     │   │   ├─ 針田 [3820101002] Harita
##     │   │   ├─ 小栗第1 [3820101003] Oguridai1
##     │   │   ├─ 小栗第2 [3820101004] Oguridai2
##     │   │   ├─ 小栗第3 [3820101005] Oguridai3
##     │   │   ├─ 藤原第1 [3820101006] Fujiwaradai1
##     │   │   ├─ 藤原第2 [3820101007] Fujiwaradai2
##     │   │   ├─ 竹原東 [3820101008] Takewarahigashi
##     │   │   ├─ 竹原西 [3820101009] Takewaranishi
##     │   │   ├─ 生石南 [3820101010] Ikushiminami
##     │   │   ├─ 生石北 [3820101011] Ikushikita
##     │   │   ├─ 八代 [3820101012] Yashiro
##     │   │   ├─ 南味酒 [3820101013] Minamimisake
##     │   │   ├─ 南江戸 [3820101014] Minamiedo
##     │   │   ├─ 朝美1 [3820101015] Asami1
##     │   │   ├─ 朝美2 [3820101016] Asami2
## ... (3570 lines omitted)
ggplot(data = b[[1]] |> filter(grepl("松山", kcity_name))) + 
  geom_sf(fill = NA) +
  geom_sf_text(aes(label = rcom_name), size = 2, family = "Hiragino Sans") +
  theme_void()

出典:農林水産省「農業集落境界データ(2025年度)」を加工して作成。

Possible values for kcity in combine_fude() and extract_boundary()

library(paletteer)

ggplot(b[[1]] |> filter(city_name == "松山市")) +
  geom_sf(aes(fill = kcity_name), alpha = .8) +
  theme_void() +
  theme(text = element_text(family = "Hiragino Sans")) +
  paletteer::scale_fill_paletteer_d("Polychrome::kelly")

出典:農林水産省「農業集落境界データ(2025年度)」を加工して作成。

Use the mapview package

If you want to use mapview(), do the following.

db1 <- combine_fude(d, b, city = "伊方町")
db2 <- combine_fude(d, b, city = "八幡浜市")
db3 <- combine_fude(d, b, city = "西予市", kcity = "三瓶|二木生|三島|双岩")

db <- bind_fude(db1, db2, db3)
db$fude <- sf::st_transform(db$fude, crs = 3857)

library(mapview)

mapview(db$fude, zcol = "rcom_name", layer.name = "農業集落名")