| Type: | Package |
| Title: | Utilities for Fude Polygon |
| Version: | 0.4.2 |
| Description: | Provides tools for reading and filtering Fude Polygon data published by Japan's Ministry of Agriculture, Forestry and Fisheries. The package also links land parcels to agricultural community boundaries and joins those boundaries with agricultural statistics. |
| 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 |
| LazyDataCompression: | xz |
| Depends: | R (≥ 4.2.0) |
| Imports: | dplyr (≥ 1.1.0), readr, readxl, sf, units |
| Suggests: | DT, leaflet, shiny, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.1 |
| NeedsCompilation: | no |
| Packaged: | 2026-11-28 04:01:18 UTC; takeshinishimura |
| Author: | Takeshi Nishimura |
| Maintainer: | Takeshi Nishimura <takenishi@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-28 04:20: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 ID/name correspondence table
Description
A dataset containing codes/names of cities in Japan.
Usage
city_id_table
Format
A data frame with 1,970 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
- id
ID
Community year/city ID correspondence table
Description
A dataset containing year/ID of communities in Japan.
Usage
city_year_id
Format
A data frame with 5,753 rows and 2 variables:
- rcom_year
Agricultural community reference year
- id
Reference ID for city_id_table
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 |
Details
Polygons with agricultural community keys are matched to the selected
boundaries by key. If the matched polygons and boundaries have different
known reference years, the function warns and returns the matches. The same
key can refer to different communities across reference years.
An error is raised if the input has keyed polygons, but none of the polygons
match the selected boundaries.
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 |
Details
Names are matched using the agricultural community reference year (rcom_year)
recorded in boundary. Use boundaries from a single reference year. If no
reference year is recorded, the 2020 lookup is used for compatibility.
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 = NULL,
rcom_year = 2025L,
boundary_type = 1,
path = NULL,
suffix = FALSE,
crs = NULL,
encoding = "CP932",
quiet = FALSE
)
Arguments
data |
A Fude Polygon data object returned by |
boundary_data_year |
The year of the boundary dataset. If |
rcom_year |
The agricultural community reference year used in the MAFF file name. Supply a single numeric or character year listed in rcom_year_id. |
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 ID/name correspondence table
Description
A dataset containing codes/names of kcities in Japan.
Usage
kcity_id_table
Format
A data frame with 12,642 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
- id
ID
Community year/Kcity ID correspondence table
Description
A dataset containing year/ID of communities in Japan.
Usage
kcity_year_id
Format
A data frame with 36,375 rows and 2 variables:
- rcom_year
Agricultural community reference year
- id
Reference ID for kcity_id_table
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
Merge Split ZIP Files of MAFF Fude Polygon Data
Description
merge_split_zip() combines split ZIP files of Fude Polygon data
provided by MAFF into a single ZIP archive.
Usage
merge_split_zip(path, output_dir = "", quiet = FALSE, overwrite = NULL)
Arguments
path |
Path to the first part ( |
output_dir |
Directory in which to save the merged ZIP file.
Defaults to the same directory as |
quiet |
Logical. If |
overwrite |
Whether to replace an existing ZIP file. If |
Details
All parts of the split ZIP archive (e.g., .zip.001, .zip.002,
and .zip.003) must be downloaded to the same directory before
running this function.
The files are concatenated in numerical order to reconstruct the original ZIP archive. Its file listing is checked before it is saved. The resulting ZIP file is not extracted. The original split files are preserved.
Value
Invisibly returns the path to the merged ZIP file, or NULL if the user
declines or cancels the overwrite prompt.
Examples
## Not run:
merge_split_zip("MB0001_2026_2025_38.zip.001")
## End(Not run)
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 4 variables:
- pref
Prefecture codes
- pref_name
Prefecture names in Kanji
- pref_kana
Prefecture names in Hiragana
- pref_romaji
Prefecture names in Romaji
Community ID/name correspondence table
Description
A dataset containing codes/names of communities in Japan.
Usage
rcom_id_table
Format
A data frame with 154,069 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
- id
ID
Community year/ID correspondence table
Description
A dataset containing year/ID of communities in Japan.
Usage
rcom_year_id
Format
A data frame with 448,296 rows and 2 variables:
- rcom_year
Agricultural community reference year
- id
Reference ID for rcom_id_table
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 = NULL,
rcom_year = NULL,
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. Defaults to 2026 when downloading. |
rcom_year |
The agricultural community boundary year used in the download file name. Defaults to 2025 for the default release. Supply this argument when downloading another release. |
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. Missing issue years are taken from
recognised layer names or, when available, the official archive name.
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 or CSV file provided by MAFF and joins its
tabular contents to agricultural community boundary data. The input file
must contain a unique ten-character key for each row. Numeric Excel keys
are padded to restore the leading zero where applicable.
Usage
read_ikasudb(boundary, path, na = c("-", "…"), zero = TRUE, rcom_year = NULL)
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 |
rcom_year |
A single four-digit agricultural community reference year for the input
statistics. If |
Details
In a file name such as IA0001_2023_2020_38.xlsx, the reference year is 2020.
An explicit rcom_year must agree with the year in a recognised file name.
Supply boundaries from a single reference year. The statistics and boundary
reference years must match when both are known. If either year is unknown,
the join uses key without a reference-year check.
Value
An sf::sf() object created by joining the input 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.