Type: Package
Title: Utilities for Fude Polygon
Version: 0.4.0
Description: Provides utilities to facilitate handling of Fude Polygon data downloadable from the Ministry of Agriculture, Forestry and Fisheries website https://open.fude.maff.go.jp.
License: MIT + file LICENSE
URL: https://github.com/takeshinishimura/fude, https://takeshinishimura.github.io/fude/
BugReports: https://github.com/takeshinishimura/fude/issues
Encoding: UTF-8
LazyData: true
Depends: R (≥ 4.1.0)
Imports: dplyr, DT, glue, leaflet, magrittr, purrr, readxl, sf, shiny, units
Suggests: testthat (≥ 3.0.0)
RoxygenNote: 7.3.3
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-03-01 13:25:26 UTC; takeshinishimura
Author: Takeshi Nishimura ORCID iD [aut, cph, cre]
Maintainer: Takeshi Nishimura <takenishi@gmail.com>
Repository: CRAN
Date/Publication: 2026-03-01 13:40:02 UTC

Bind multiple Fude Polygon data

Description

bind_fude() binds a list of polygon data. It also binds a list of data combined by combine_fude().

Usage

bind_fude(...)

Arguments

...

Database lists to be combined. They should all have the same named elements.

Value

A list of sf::sf() object(s).

See Also

read_fude(), combine_fude().

Examples

path <- system.file("extdata", "castle.zip", package = "fude")
d1 <- read_fude(path, quiet = TRUE)
d2 <- read_fude(path, quiet = TRUE)
bind_fude(d1, d2)


Generate citation text for Fude Polygon data

Description

Generates citation text in Japanese and English for Fude Polygon Data.

Usage

cite_fude(data)

Arguments

data

A list or data frame containing Fude Polygon data.

Value

A list with two elements: ja for Japanese citation text and en for English citation text.


City code/name correspondence table

Description

A dataset containing codes/names of cities in Japan.

Usage

city_code_table

Format

A data frame with 1,905 rows and 9 variables:

key

Unique city codes

pref_name

Prefecture names in Kanji

pref_kana

Prefecture names in Hiragana

pref_romaji

Prefecture names in Romaji

city_name

City names in Kanji

city_kana

City names in Hiragana

city_romaji

City names in Romaji

local_government_cd

Local government codes

census_year

Year of the census from which the data is derived


Combine the Fude Polygon data with the agricultural community boundary data

Description

combine_fude() uses the agricultural community boundary data to reduce the Fude Polygon data to the community units.

Usage

combine_fude(data, boundary, city, kcity = "", rcom = "", year = NULL)

Arguments

data

Fude Polygon data as returned by read_fude().

boundary

Agricultural community boundary data as returned by get_boundary().

city

A character vector of local government names or 6-digit local government codes to extract.

kcity

A regular expression. One or more former municipality names (in Japanese) to extract.

rcom

A regular expression. One or more agricultural community names (in Japanese) to extract.

year

Year in the column name of the data. If there is more than one applicable local government code, it is required.

Value

A list of sf::sf() objects.

See Also

read_fude().

Examples


path <- system.file("extdata", "castle.zip", package = "fude")
d <- read_fude(path, stringsAsFactors = FALSE)
b <- get_boundary(d)
db <- combine_fude(d, b, "\u677e\u5c71\u5e02", "\u57ce\u6771", year = 2022)


Extract specified agricultural community boundary data

Description

extract_boundary() extracts specified subsets of agricultural community boundary data returned by get_boundary().

Usage

extract_boundary(boundary, city = "", kcity = "", rcom = "", layer = FALSE)

Arguments

boundary

Agricultural community boundary data as returned by get_boundary().

city

A character vector of local government names or 6-digit local government codes to extract.

kcity

A regular expression. One or more former municipality names (in Japanese) to extract.

rcom

A regular expression. One or more agricultural community names (in Japanese) to extract.

layer

Logical. If TRUE, the returned object includes not only agricultural community boundaries but also prefecture and municipality boundaries.

Value

An sf::sf() object.

See Also

read_fude().


Extract specified Fude Polygon data

Description

extract_fude() extracts specified subsets of Fude Polygon data returned by read_fude().

Usage

extract_fude(data, year = NULL, city = NULL, kcity = "", rcom = "")

Arguments

data

Fude Polygon data as returned by read_fude().

year

A numeric vector of years to extract.

city

A character vector of local government names or 6-digit local government codes to extract.

kcity

A regular expression. One or more former municipality names (in Japanese) to extract.

rcom

A regular expression. One or more agricultural community names (in Japanese) to extract.

Value

An sf::sf() object.

See Also

read_fude().


Get the agricultural community boundary data

Description

get_boundary() downloads and reads one or more agricultural community boundary data provided by the MAFF.

Usage

get_boundary(
  data,
  boundary_data_year = 2020,
  rcom_year = 2020,
  boundary_type = 1,
  path = NULL,
  suffix = FALSE,
  to_wgs84 = TRUE,
  encoding = "CP932",
  quiet = FALSE
)

Arguments

data

Either Fude Polygon data as returned by read_fude(), or a two-digit prefecture code.

boundary_data_year

Year when the agricultural community boundary data were created.

rcom_year

Year of the agricultural community boundary data.

boundary_type

The type of boundary data: 1 = agricultural community, 2 = former municipality, 3 = municipality.

path

Path to the ZIP file containing the agricultural community boundary data; use a local ZIP file instead of going looking for a ZIP file. Specify a directory containing one or more ZIP files, not the ZIP file itself.

suffix

Logical. If FALSE, suffixes such as "-SHI" and "-KU" in local government names are removed.

to_wgs84

Logical. If TRUE, transform coordinates to WGS 84 (EPSG:4326).

encoding

Character encoding of the source files (e.g., "CP932").

quiet

Logical. If TRUE, suppress messages about reading progress.

Value

A list of sf::sf() objects.

Examples


path <- system.file("extdata", "castle.zip", package = "fude")
d <- read_fude(path)
b <- get_boundary(d)


Kcity code/name correspondence table

Description

A dataset containing codes/names of kcities in Japan.

Usage

kcity_code_table

Format

A data frame with 12,110 rows and 10 variables:

key

Unique kcity codes

pref_name

Prefecture names in Kanji

pref_kana

Prefecture names in Hiragana

pref_romaji

Prefecture names in Romaji

city_name

City names in Kanji

city_kana

City names in Hiragana

city_romaji

City names in Romaji

kcity_name

Former city names in Kanji

local_government_cd

Local government codes

census_year

Year of the census from which the data is derived


Local government code/name correspondence table

Description

A dataset containing codes/names of local governments in Japan.

Usage

lg_code_table

Format

A data frame with 1,992 rows and 6 variables:

lg_code

Local government codes

pref_kanji

Prefecture names in Kanji

city_kanji

Local government names in Kanji

pref_kana

Prefecture names in Katakana

city_kana

Local government names in Katakana

romaji

Local government names in Romaji


Inspect the Structure of Fude Polygon Data

Description

ls_fude() lists the year and the local government names (or codes) in order to understand what is included in the list returned by read_fude().

Usage

ls_fude(data)

Arguments

data

Fude Polygon data as returned by read_fude().

Value

A data frame.

See Also

read_fude().


Prefecture code/name correspondence table

Description

A dataset containing codes/names of prefectures in Japan.

Usage

pref_code_table

Format

A data frame with 47 rows and 2 variables:

pref_code

Prefecture codes

pref_kanji

Prefecture names in Kanji


Community code/name correspondence table

Description

A dataset containing codes/names of communities in Japan.

Usage

rcom_code_table

Format

A data frame with 149,511 rows and 13 variables:

key

Unique community codes

pref_name

Prefecture names in Kanji

pref_kana

Prefecture names in Hiragana

pref_romaji

Prefecture names in Romaji

city_name

City names in Kanji

city_kana

City names in Hiragana

city_romaji

City names in Romaji

kcity_name

Former village names in Kanji

rcom_name

Community names in Kanji

rcom_kana

Community names in Hiragana

rcom_romaji

Community names in Romaji

local_government_cd

Local government codes

census_year

Year of the census from which the data is derived


Read a Fude Polygon ZIP file

Description

read_fude() reads MAFF Fude Polygon data from a ZIP file and returns the layers as a list of sf::sf() objects. The ZIP may contain one or more spatial data files such as GeoJSON (.json or .geojson) and FlatGeobuf (.fgb). The function also works with ZIP files you created, as long as the original filenames are unchanged.

Usage

read_fude(
  path = NULL,
  pref = NULL,
  year = 2025,
  rcom_year = 2020,
  supplementary = FALSE,
  to_wgs84 = TRUE,
  quiet = FALSE
)

Arguments

path

Path to a ZIP file containing one or more supported spatial files (.geojson, .json, and .fgb).

pref

Prefecture name or a two-digit prefecture code.

year

Year when the Fude Polygon data were created.

rcom_year

Year of the agricultural community boundary data.

supplementary

Logical. If TRUE, add supplementary information for each polygon.

to_wgs84

Logical. If TRUE, transform coordinates to WGS 84 (EPSG:4326).

quiet

Logical. If TRUE, suppress messages about reading progress.

Value

A list of sf::sf() objects.

Examples

path <- system.file("extdata", "castle.zip", package = "fude")
d <- read_fude(path)


Read a shuraku Excel file

Description

read_ikasudb() reads a shuraku Excel file provided by MAFF.

Usage

read_ikasudb(boundary, path, na = c("-", "…"), zero = TRUE)

Arguments

boundary

Agricultural community boundary data as returned by get_boundary().

path

Path to an .xlsx file.

na

Character vector of strings to interpret as missing values. Defaults to c("-", "\u2026").

zero

Logical. If TRUE, treat masked values ("x" and "X") as zero.

Value

An sf::sf() object.


Rename the Fude Polygon data

Description

rename_fude() renames the 6-digit local government code of the list returned by read_fude() to the corresponding Japanese name in order to make the data human-friendly.

Usage

rename_fude(data, suffix = TRUE, romaji = NULL, quiet = TRUE)

Arguments

data

Fude Polygon data as returned by read_fude().

suffix

Logical. If FALSE, suffixes such as "-SHI" and "-KU" in local government names are removed.

romaji

If not NULL, rename the local government name in romaji instead of Japanese. Romanji format is upper case unless specified.

  • "title": Title case.

  • "lower": Lower case.

  • "upper": Upper case.

quiet

Logical. Suppress information about the data to be read.

Value

A list of sf::sf() objects.

See Also

read_fude().

Examples

path <- system.file("extdata", "castle.zip", package = "fude")
d <- read_fude(path, quiet = FALSE)
d2 <- rename_fude(d)
d2 <- rename_fude(d, suffix = FALSE)
d2 <- d |> rename_fude(romaji = "upper")


Prepare Leaflet map for Fude Polygon data

Description

Prepares a Leaflet map for Fude Polygon data.

Usage

shiny_fude(data, height = 1000, rcom = FALSE)

Arguments

data

A list or data frame containing Fude Polygon data.

height

Height of the map.

rcom

A logical value indicating whether to overlay community data on the map.

Value

A Leaflet map object with Fude Polygon data with an HTML table.