| Type: | Package |
| Title: | Utilities for Fude Polygon |
| Version: | 0.4.1 |
| 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.2.0) |
| Imports: | dplyr, readr, readxl, sf, units |
| Suggests: | DT, leaflet, shiny, testthat (≥ 3.0.0) |
| RoxygenNote: | 7.3.3 |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-04-05 04:36:54 UTC; takeshinishimura |
| Author: | Takeshi Nishimura |
| Maintainer: | Takeshi Nishimura <takenishi@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-05 04:50:02 UTC |
Bind multiple Fude Polygon data objects
Description
bind_fude() combines multiple Fude Polygon data objects by binding elements
with the same names across inputs. It can also be used on objects that have
already been combined by combine_fude().
Usage
bind_fude(...)
Arguments
... |
Two or more Fude Polygon data objects to combine. Named elements that appear
in multiple inputs are row-bound into a single |
Value
A named list of sf::sf() objects.
See Also
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
cite_fude() generates citation text in Japanese and English from Fude
Polygon data and related boundary data.
Usage
cite_fude(data)
Arguments
data |
A Fude Polygon data object, boundary data object, or a data frame/list
containing |
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 Fude Polygon data with agricultural community boundary data
Description
combine_fude() combines Fude Polygon data with agricultural community
boundary data and returns the polygons associated with the specified
municipality, former municipality, and/or agricultural community.
Usage
combine_fude(data, boundary, city, kcity = "", rcom = "", year = NULL)
Arguments
data |
A Fude Polygon data object returned by |
boundary |
Agricultural community boundary data returned by |
city |
A character vector of municipality names or local government codes used to
identify target municipalities. If |
kcity |
A character vector of regular expression patterns used to match former municipality names in Japanese. |
rcom |
A character vector of regular expression patterns used to match agricultural community names in Japanese. |
year |
Numeric scalar or |
Value
A named list of sf::sf() objects.
See Also
Examples
path <- system.file("extdata", "castle.zip", package = "fude")
d <- read_fude(path)
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 subsets of agricultural community boundary data
returned by get_boundary() by municipality, former municipality, and/or
agricultural community.
Usage
extract_boundary(boundary, city = "", kcity = "", rcom = "", layer = FALSE)
Arguments
boundary |
Agricultural community boundary data returned by |
city |
A character vector of municipality names or local government codes used to
identify target municipalities. If |
kcity |
A character vector of regular expression patterns used to match former municipality names in Japanese. |
rcom |
A character vector of regular expression patterns used to match agricultural community names in Japanese. |
layer |
Logical. If |
Value
If layer = FALSE, an sf::sf() object. If layer = TRUE, a named list of
sf::sf() objects.
See Also
Extract a subset of Fude Polygon data
Description
extract_fude() extracts a subset of Fude Polygon data returned by
read_fude() by year, municipality, former municipality, and/or
agricultural community.
Usage
extract_fude(data, year = NULL, city = NULL, kcity = "", rcom = "")
Arguments
data |
A Fude Polygon data object returned by |
year |
A numeric vector of issue years to extract. If |
city |
A character vector of municipality names or local government codes used to
identify target municipalities. If |
kcity |
A character vector of regular expression patterns used to match former municipality names in Japanese. |
rcom |
A character vector of regular expression patterns used to match agricultural community names in Japanese. |
Value
An sf::sf() object containing the extracted subset.
See Also
Get agricultural community boundary data
Description
get_boundary() downloads and reads one or more MAFF agricultural community
boundary datasets and returns them as a named list of sf::sf() objects.
The target prefectures are determined from data.
Usage
get_boundary(
data,
boundary_data_year = 2020,
rcom_year = 2020,
boundary_type = 1,
path = NULL,
suffix = FALSE,
crs = NULL,
encoding = "CP932",
quiet = FALSE
)
Arguments
data |
Either a Fude Polygon data object returned by |
boundary_data_year |
The year of the boundary dataset. |
rcom_year |
The agricultural community reference year used in the MAFF file name. |
boundary_type |
Integer specifying the boundary level to read: |
path |
Path to a directory containing boundary ZIP files. If |
suffix |
Logical. If |
crs |
Coordinate reference system to transform the output data to. If |
encoding |
Character encoding of the source shapefile attributes, such as |
quiet |
Logical. If |
Value
A named 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
List the contents of Fude Polygon data
Description
ls_fude() summarizes the contents of a Fude Polygon data object returned by
read_fude(). It reports the data name, issue year, local government code,
number of records, and corresponding prefecture and municipality names.
Usage
ls_fude(data)
Arguments
data |
A Fude Polygon data object returned by |
Value
A data frame with one row per combination of data name, issue year, and local government code.
See Also
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 Fude Polygon data from a ZIP file
Description
read_fude() reads MAFF Fude Polygon data from a ZIP file and returns the
layers as a named list of sf::sf() objects. If path is not supplied, the
function downloads the ZIP file for the specified prefecture and year using
pref, year, and rcom_year.
The ZIP archive may contain one or more supported spatial files in GeoJSON
(.json or .geojson) or FlatGeobuf (.fgb) format. The function also
works with ZIP files created manually, provided that the original file names
are preserved.
Usage
read_fude(
path = NULL,
pref = NULL,
year = 2025,
rcom_year = 2020,
crs = NULL,
supplementary = FALSE,
quiet = FALSE
)
Arguments
path |
Path to a ZIP file containing one or more supported spatial files. If |
pref |
Prefecture name or prefecture code used when downloading data. Ignored if
|
year |
The Fude Polygon data year used in the download file name. |
rcom_year |
The agricultural community boundary year used in the download file name. |
crs |
Coordinate reference system to transform the output layers to. If |
supplementary |
Logical. If |
quiet |
Logical. If |
Value
A named 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 and joins its
tabular contents to agricultural community boundary data.
Usage
read_ikasudb(boundary, path, na = c("-", "…"), zero = TRUE)
Arguments
boundary |
Agricultural community boundary data, typically returned by |
path |
Path to an |
na |
Character vector of strings to interpret as missing values. Defaults to
|
zero |
Logical. If |
Value
An sf::sf() object created by joining the Excel data to boundary.
See Also
Rename Fude Polygon data
Description
rename_fude() renames the elements of a Fude Polygon data object returned
by read_fude() by replacing local government codes in the element names
with corresponding municipality names, making the object easier to read.
Usage
rename_fude(data, suffix = TRUE, romaji = NULL, quiet = TRUE)
Arguments
data |
A Fude Polygon data object returned by |
suffix |
Logical. If |
romaji |
Character scalar or |
quiet |
Logical. If |
Value
A Fude Polygon data object with renamed elements.
See Also
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 <- rename_fude(d, romaji = "upper")
Prepare a Shiny Leaflet viewer for Fude Polygon data
Description
shiny_fude() prepares a Shiny user interface and server function for
interactive visualization of Fude Polygon data with leaflet and DT.
The map supports polygon selection, optional agricultural community boundary
overlays, and a linked attribute table.
Usage
shiny_fude(data, height = 1000, rcom = FALSE)
Arguments
data |
A Fude Polygon data object, or a list containing |
height |
Height of the map passed to |
rcom |
Logical. If |
Value
A list with two elements: ui, a Shiny UI object, and server, a Shiny
server function.