| Title: | Utilities for Fude Polygon |
|---|---|
| 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>. |
| Authors: | Takeshi Nishimura [aut, cph, cre] (ORCID: <https://orcid.org/0000-0003-1761-4300>) |
| Maintainer: | Takeshi Nishimura <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.1.9000 |
| Built: | 2026-05-26 10:34:46 UTC |
| Source: | https://github.com/takeshinishimura/fude |
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().
bind_fude(...)bind_fude(...)
... |
Two or more Fude Polygon data objects to combine. Named elements that appear
in multiple inputs are row-bound into a single |
A named list of sf::sf() objects.
path <- system.file("extdata", "castle.zip", package = "fude") d1 <- read_fude(path, quiet = TRUE) d2 <- read_fude(path, quiet = TRUE) bind_fude(d1, d2)path <- system.file("extdata", "castle.zip", package = "fude") d1 <- read_fude(path, quiet = TRUE) d2 <- read_fude(path, quiet = TRUE) bind_fude(d1, d2)
cite_fude() generates citation text in Japanese and English from Fude
Polygon data and related boundary data.
cite_fude(data)cite_fude(data)
data |
A Fude Polygon data object, boundary data object, or a data frame/list
containing |
A list with two elements: ja for Japanese citation text and en for
English citation text.
A dataset containing codes/names of cities in Japan.
city_id_tablecity_id_table
A data frame with 1,970 rows and 9 variables:
Unique city codes
Prefecture names in Kanji
Prefecture names in Hiragana
Prefecture names in Romaji
City names in Kanji
City names in Hiragana
City names in Romaji
Local government codes
ID
A dataset containing year/ID of communities in Japan.
city_year_idcity_year_id
A data frame with 5,753 rows and 2 variables:
Agricultural community reference year
Reference ID for city_id_table
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.
combine_fude(data, boundary, city, kcity = "", rcom = "", year = NULL)combine_fude(data, boundary, city, kcity = "", rcom = "", year = NULL)
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 |
A named list of sf::sf() objects.
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)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_boundary() extracts subsets of agricultural community boundary data
returned by get_boundary() by municipality, former municipality, and/or
agricultural community.
extract_boundary(boundary, city = "", kcity = "", rcom = "", layer = FALSE)extract_boundary(boundary, city = "", kcity = "", rcom = "", layer = FALSE)
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 |
If layer = FALSE, an sf::sf() object. If layer = TRUE, a named list of
sf::sf() objects.
extract_fude() extracts a subset of Fude Polygon data returned by
read_fude() by year, municipality, former municipality, and/or
agricultural community.
extract_fude(data, year = NULL, city = NULL, kcity = "", rcom = "")extract_fude(data, year = NULL, city = NULL, kcity = "", rcom = "")
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. |
An sf::sf() object containing the extracted subset.
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.
get_boundary( data, boundary_data_year = NULL, rcom_year = 2020, boundary_type = 1, path = NULL, suffix = FALSE, crs = NULL, encoding = "CP932", quiet = FALSE )get_boundary( data, boundary_data_year = NULL, rcom_year = 2020, boundary_type = 1, path = NULL, suffix = FALSE, crs = NULL, encoding = "CP932", quiet = FALSE )
data |
Either 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. |
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 |
A named list of sf::sf() objects.
path <- system.file("extdata", "castle.zip", package = "fude") d <- read_fude(path) b <- get_boundary(d)path <- system.file("extdata", "castle.zip", package = "fude") d <- read_fude(path) b <- get_boundary(d)
A dataset containing codes/names of kcities in Japan.
kcity_id_tablekcity_id_table
A data frame with 12,642 rows and 10 variables:
Unique kcity codes
Prefecture names in Kanji
Prefecture names in Hiragana
Prefecture names in Romaji
City names in Kanji
City names in Hiragana
City names in Romaji
Former city names in Kanji
Local government codes
ID
A dataset containing year/ID of communities in Japan.
kcity_year_idkcity_year_id
A data frame with 36,375 rows and 2 variables:
Agricultural community reference year
Reference ID for kcity_id_table
A dataset containing codes/names of local governments in Japan.
lg_code_tablelg_code_table
A data frame with 1,992 rows and 6 variables:
Local government codes
Prefecture names in Kanji
Local government names in Kanji
Prefecture names in Katakana
Local government names in Katakana
Local government names in Romaji
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.
ls_fude(data)ls_fude(data)
data |
A Fude Polygon data object returned by |
A data frame with one row per combination of data name, issue year, and local government code.
A dataset containing codes/names of prefectures in Japan.
pref_code_tablepref_code_table
A data frame with 47 rows and 4 variables:
Prefecture codes
Prefecture names in Kanji
Prefecture names in Hiragana
Prefecture names in Romaji
A dataset containing codes/names of communities in Japan.
rcom_id_tablercom_id_table
A data frame with 154,069 rows and 13 variables:
Unique community codes
Prefecture names in Kanji
Prefecture names in Hiragana
Prefecture names in Romaji
City names in Kanji
City names in Hiragana
City names in Romaji
Former village names in Kanji
Community names in Kanji
Community names in Hiragana
Community names in Romaji
Local government codes
ID
A dataset containing year/ID of communities in Japan.
rcom_year_idrcom_year_id
A data frame with 448,296 rows and 2 variables:
Agricultural community reference year
Reference ID for rcom_id_table
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.
read_fude( path = NULL, pref = NULL, year = 2025, rcom_year = 2020, crs = NULL, supplementary = FALSE, quiet = FALSE )read_fude( path = NULL, pref = NULL, year = 2025, rcom_year = 2020, crs = NULL, supplementary = FALSE, quiet = FALSE )
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 |
A named list of sf::sf() objects.
path <- system.file("extdata", "castle.zip", package = "fude") d <- read_fude(path)path <- system.file("extdata", "castle.zip", package = "fude") d <- read_fude(path)
read_ikasudb() reads a shuraku Excel file provided by MAFF and joins its
tabular contents to agricultural community boundary data.
read_ikasudb(boundary, path, na = c("-", "…"), zero = TRUE)read_ikasudb(boundary, path, na = c("-", "…"), zero = TRUE)
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 |
An sf::sf() object created by joining the Excel data to boundary.
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.
rename_fude(data, suffix = TRUE, romaji = NULL, quiet = TRUE)rename_fude(data, suffix = TRUE, romaji = NULL, quiet = TRUE)
data |
A Fude Polygon data object returned by |
suffix |
Logical. If |
romaji |
Character scalar or |
quiet |
Logical. If |
A Fude Polygon data object with renamed elements.
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")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")
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.
shiny_fude(data, height = 1000, rcom = FALSE)shiny_fude(data, height = 1000, rcom = FALSE)
data |
A Fude Polygon data object, or a list containing |
height |
Height of the map passed to |
rcom |
Logical. If |
A list with two elements: ui, a Shiny UI object, and server, a Shiny
server function.