Skip to contents

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 get_boundary(). This can be a single boundary object or a list of boundary objects.

path

Path to an .xlsx file provided by MAFF or a .csv 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 before numeric conversion.

rcom_year

A single four-digit agricultural community reference year for the input statistics. If NULL, use the reference year in a recognised MAFF file name.

Value

An sf::sf() object created by joining the input data to boundary. The ikasudb_sources attribute records the file name (without its directory), source data year, and community reference year for use by cite_fude(). Unknown years are recorded as NA.

Details

In a file name such as IA0001_2023_2020_38.xlsx, the source data year is 2023 and the agricultural community 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. If the statistics and boundaries use different known reference years, the function warns and joins by key. Matching keys may refer to different communities across reference years. If either year is unknown, the join uses key without a year check.