The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Import Boundary Data

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:

Load Prefecture Data

jp_map() returns an sf object. Without extra options, prefecture maps use the first available all-Japan prefecture file.

prefectures <- jp_map("prefecture")
prefectures

Load Okinawa Municipal Data

The companion data package can provide official MLIT N03 municipal boundaries for Okinawa Prefecture as of January 1, 2024.

okinawa_municipalities <- jp_map("municipality", include = "Okinawa")
okinawa_municipalities

This works without data_year or data_dir when jpmap can see the Okinawa file through jpmapdata or jpmap_data_dir().

Load Locally Built Municipal Data

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.

ehime_municipalities <- jp_map(
  "municipality",
  include = "Ehime",
  data_year = 2024,
  data_dir = "jpmap-data"
)

Inspect A GeoPackage

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.

municipalities <- sf::st_read(okinawa_file, layer = "municipalities")

File Names

jpmap recognizes these file names:

The PP suffix is the two-digit prefecture code, such as 38 for Ehime and 47 for Okinawa.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.