Use available_jpmap_data() to see which boundary files
jpmap can find.
library(jpmap)
available <- if (jpmap_build_full_vignettes) {
available_jpmap_data()
} else {
available_jpmap_data(data_dir = tempfile())
}
jpmap_has_boundary_data <- nrow(available) > 0
jpmap_has_okinawa_data <- any(available$year == 2024 & available$pref_code == "47")
available_summary <- available[c("year", "pref_code", "prefecture", "source")]
row.names(available_summary) <- NULL
available_summary
#> [1] year pref_code prefecture source
#> <0 rows> (or 0-length row.names)The package checks two locations:
jpmapdata
package;jpmap_data_dir(), unless you pass a
custom data_dir.jp_map() returns an sf object. Without
extra options, prefecture maps use the first available all-Japan
prefecture file.
The companion data package can provide official MLIT N03 municipal boundaries for Okinawa Prefecture as of January 1, 2024.
This works without data_year or data_dir
when jpmap can see the Okinawa file through
jpmapdata or jpmap_data_dir().
After building a local file, use the same include value
to select the prefecture.
jpmap_build_data(year = 2024, prefecture = "Ehime")
ehime_municipalities <- jp_map("municipality", include = "Ehime", data_year = 2024)If you saved the file somewhere else, pass that folder as
data_dir.
The GeoPackage layers are ordinary spatial data layers, so you can
inspect them with sf.
okinawa_file <- available$path[available$year == 2024 & available$pref_code == "47"]
sf::st_layers(okinawa_file)Read a layer directly only when you need lower-level control. Most
map workflows can use jp_map() instead.
jpmap recognizes these file names:
jpmap_boundaries_YYYY.gpkg for national data;jpmap_boundaries_YYYY_PP.gpkg for one-prefecture
data.The PP suffix is the two-digit prefecture code, such as
38 for Ehime and 47 for Okinawa.