Skip to contents

jpmap uses GeoPackage files with two layers:

  • prefectures
  • municipalities

Ready-to-use boundary files can be supplied by the companion jpmapdata package. You can also build your own GeoPackage files from MLIT N03 administrative area data. The 2024 MLIT N03 files describe administrative boundaries as of January 1, 2024.

Where Files Are Saved

By default, jpmap_build_data() saves converted GeoPackage files in the package data directory returned by jpmap_data_dir().

library(jpmap)

# Run this locally to see your user-specific data directory.
jpmap_data_dir(create = FALSE)

The exact value is different on each computer, so the website does not print a live path. You do not need to create this directory by hand. jpmap_build_data() creates it when needed.

Build One Prefecture

For most municipal examples, start with one prefecture. This downloads a smaller official MLIT N03 archive, converts it to a GeoPackage, and saves it in jpmap_data_dir().

jpmap_build_data(year = 2024, prefecture = "Ehime")

The generated file is named with the prefecture code:

jpmap_boundaries_2024_38.gpkg

For Okinawa, the companion data package can provide the 2024 file:

jpmap_boundaries_2024_47.gpkg

Build All Municipalities

Build nationwide municipal data only when you need all municipalities. The official 2024 national source archive is about 583 MB, and the converted GeoPackage is also large.

jpmap_build_data(year = 2024)

The generated national file is named:

jpmap_boundaries_2024.gpkg

Source URLs

The source is MLIT National Land Numerical Information N03 administrative area data:

The filename pattern is N03-YYYY0101_GML.zip for national data and N03-YYYY0101_PP_GML.zip for one-prefecture data, where PP is a two-digit prefecture code.

Custom Location

If you want to keep boundary data in a project folder instead of the default user data directory, pass destdir.

dir.create("jpmap-data", showWarnings = FALSE)
jpmap_build_data(year = 2024, prefecture = "Ehime", destdir = "jpmap-data")

Use the same folder later with data_dir.

jp_map("municipality", include = "Ehime", data_dir = "jpmap-data")