Download e-Stat administrative boundaries as an sf object
Source:R/boundaries.R
estat_boundaries.RdFetches official e-Stat census boundary polygons and returns them as an
sf object with an area_code column matching the codes used by
get_estat(), so
the two join cleanly. Boundaries are derived from e-Stat's authoritative
small-area (町丁・字) shapefiles and dissolved to the requested level.
Arguments
- areas
Character vector of area codes selecting which prefectures to download: 2-digit prefecture codes (e.g.
"31") or any codes whose first two digits are a prefecture (e.g. a 5-digit"31201"or thearea_codecolumn fromget_estat()).NULLdownloads all 47 prefectures (large).- level
Geographic level to return:
"municipality"(default; 5-digitPREF+CITY) or"prefecture"(dissolved whole prefectures,PREF+"000") or"small_area"(raw 町丁・字, 9-digitKEY_CODE).- year
Census year of the boundaries (e.g.
2020,2015). Match this to the census year of your data: municipality codes and boundaries change between censuses (mergers), so a mismatched year can mis-join.- datum
Geodetic datum:
"2000"(JGD2000, EPSG:4612, default) or"2011"(JGD2011, EPSG:6668).- cache
If
TRUE(default), cache downloaded boundary files underestat_cache_dir().- designated_cities
How to handle the 20 ordinance-designated cities and Tokyo's special wards at
level = "municipality", since e-Stat's shapefiles carry only ward codes:"both"(default) returns ward polygons and a unioned parent-city polygon (e.g. both01101… and01100札幌市), so data coded at either level joins;"ward"returns wards only;"city"returns the parent city only. Ignored for other levels.
Value
An sf object with area_code, name columns, and geometry.
Details
Requires the sf package. Downloaded files are cached (see
estat_cache_dir()).