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]
|
Maintainer: | Takeshi Nishimura <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.7.9000 |
Built: | 2025-02-21 06:01:57 UTC |
Source: | https://github.com/takeshinishimura/fude |
bind_fude()
binds a list of polygon data. It also binds a list of data
combined by combine_fude()
.
bind_fude(...)
bind_fude(...)
... |
Database lists to be combined. They should all have the same named elements. |
A list of sf::sf()
object(s).
path <- system.file("extdata", "castle.zip", package = "fude") d1 <- read_fude(path, stringsAsFactors = FALSE, quiet = TRUE) d2 <- read_fude(path, stringsAsFactors = FALSE, quiet = TRUE) bind_fude(d1, d2)
path <- system.file("extdata", "castle.zip", package = "fude") d1 <- read_fude(path, stringsAsFactors = FALSE, quiet = TRUE) d2 <- read_fude(path, stringsAsFactors = FALSE, quiet = TRUE) bind_fude(d1, d2)
Generates citation text in Japanese and English for Fude Polygon Data.
cite_fude(data)
cite_fude(data)
data |
A list or data frame containing Fude Polygon data. |
A list with two elements: ja
for Japanese citation text and en
for English citation text.
data <- list(fude = data.frame(issue_year = c(2021, 2020), boundary_edit_year = c(2019, 2020))) cite_fude(data)
data <- list(fude = data.frame(issue_year = c(2021, 2020), boundary_edit_year = c(2019, 2020))) cite_fude(data)
combine_fude()
uses the agricultural community boundary data to reduce the
Fude Polygon data to the community units.
combine_fude(data, boundary, city, kcity = "", community = "", year = NULL)
combine_fude(data, boundary, city, kcity = "", community = "", year = NULL)
data |
List of |
boundary |
List of one or more agricultural community boundary data provided by the MAFF. |
city |
A local government name in Japanese to be extracted. In the case of overlapping local government names, this must contain the prefecture name in Japanese and the prefecture code in romaji (e.g., "Fuchu-shi, 13", "fuchu 13", "34 fuchu-shi", "34, FUCHU-CHO"). Alternatively, it could be a 6-digit local government code. |
kcity |
String by regular expression. One or more former village name in Japanese to be extracted. |
community |
String by regular expression. One or more agricultural community name in Japanese to be extracted. |
year |
Year in the column name of the |
A list of sf::sf()
objects.
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)
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)
A dataset containing codes/names of communities in Japan.
community_code_table
community_code_table
A data frame with 149,511 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
The year of the census from which the data is derived
extract_boundary()
extracts the specified data from the list returned by
get_boundary()
.
extract_boundary(boundary, city = "", kcity = "", community = "", all = FALSE)
extract_boundary(boundary, city = "", kcity = "", community = "", all = FALSE)
boundary |
List of one or more agricultural community boundary data provided by the MAFF. |
city |
A local government name in Japanese to be extracted. In the case of overlapping local government names, this must contain the prefecture name in Japanese and the prefecture code in romaji (e.g., "Fuchu-shi, 13", "fuchu 13", "34 fuchu-shi", "34, FUCHU-CHO"). Alternatively, it could be a 6-digit local government code. |
kcity |
String by regular expression. One or more former village name in Japanese to be extracted. |
community |
String by regular expression. One or more agricultural community name in Japanese to be extracted. |
all |
logical. |
A list of sf::sf()
object(s).
extract_fude()
extracts the specified data from the list returned by
read_fude()
.
extract_fude( data, year = NULL, city = NULL, kcity = "", community = "", list = TRUE )
extract_fude( data, year = NULL, city = NULL, kcity = "", community = "", list = TRUE )
data |
List of |
year |
Years to be extracted. |
city |
Local government names or codes to be extracted. |
kcity |
String by regular expression. One or more former village name in Japanese to be extracted. |
community |
String by regular expression. One or more agricultural community name in Japanese to be extracted. |
list |
logical. If |
A list of sf::sf()
object(s).
get_boundary()
downloads and reads one or more agricultural community
boundary data provided by the MAFF.
get_boundary( data, year = 2020, census_year = 2020, path = NULL, to_wgs84 = TRUE, quiet = FALSE )
get_boundary( data, year = 2020, census_year = 2020, path = NULL, to_wgs84 = TRUE, quiet = FALSE )
data |
List of |
year |
The year when the agricultural community boundary data was created. |
census_year |
The year of the Agricultural and Forestry Census. |
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. |
to_wgs84 |
logical. Convert JGD2000 to WGS 84. |
quiet |
logical. Suppress information about the data to be read. |
A 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 local governments in Japan.
lg_code_table
lg_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()
lists the year and the local government names (or codes) in
order to understand what is included in the list returned by read_fude()
.
ls_fude(data)
ls_fude(data)
data |
List of |
A data.frame.
A dataset containing codes/names of prefectures in Japan.
pref_code_table
pref_code_table
A data frame with 47 rows and 2 variables:
Prefecture codes
Prefecture names in Kanji
read_fude()
reads Fude Polygon data as a list. The data can be downloaded
from the MAFF website as a ZIP file, which contains one or more spatial data
files, such as GeoJSON files (.json
or .geojson
) and FlatGeobuf
files (.fgb
). The function also works with ZIP files you created, as long
as you do not change the filenames of the original files.
read_fude( path = NULL, pref = NULL, year = 2024, census_year = 2020, stringsAsFactors = FALSE, supplementary = FALSE, to_wgs84 = TRUE, quiet = FALSE )
read_fude( path = NULL, pref = NULL, year = 2024, census_year = 2020, stringsAsFactors = FALSE, supplementary = FALSE, to_wgs84 = TRUE, quiet = FALSE )
path |
Path to the ZIP file containing one or more supported spatial data files.
Supported formats include |
pref |
The year when the Fude Polygon data was created. |
year |
The year when the Fude Polygon data was created. |
census_year |
The year of the Agricultural and Forestry Census. |
stringsAsFactors |
logical. Should character vectors be converted to factors? |
supplementary |
logical. If TRUE, add supplementary information for each polygon. |
to_wgs84 |
logical. Convert JGD2000 to WGS 84. |
quiet |
logical. Suppress information about the data to be read. |
A list of sf::sf()
objects.
path <- system.file("extdata", "castle.zip", package = "fude") d <- read_fude(path, stringsAsFactors = FALSE)
path <- system.file("extdata", "castle.zip", package = "fude") d <- read_fude(path, stringsAsFactors = FALSE)
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.
rename_fude(data, suffix = TRUE, romaji = NULL, quiet = TRUE)
rename_fude(data, suffix = TRUE, romaji = NULL, quiet = TRUE)
data |
List of |
suffix |
logical. If |
romaji |
If not
|
quiet |
logical. Suppress information about the data to be read. |
A list of sf::sf()
objects.
path <- system.file("extdata", "castle.zip", package = "fude") d <- read_fude(path, stringsAsFactors = FALSE, quiet = FALSE) d2 <- rename_fude(d) d2 <- rename_fude(d, suffix = FALSE) d2 <- d |> rename_fude(romaji = "upper")
path <- system.file("extdata", "castle.zip", package = "fude") d <- read_fude(path, stringsAsFactors = FALSE, quiet = FALSE) d2 <- rename_fude(d) d2 <- rename_fude(d, suffix = FALSE) d2 <- d |> rename_fude(romaji = "upper")
Prepares a Leaflet map for Fude Polygon data.
shiny_fude(data, community = FALSE)
shiny_fude(data, community = FALSE)
data |
A list or data frame containing Fude Polygon data. |
community |
A logical value indicating whether to overlay community data on the map. |
A Leaflet map object with Fude Polygon data with an HTML table.