Skip to content

pycensus.census.countries.taiwan.moi.loader

Loader for Taiwan's MOI RIS resident population, returning a common-schema GeoDataFrame.

Technical aspects

Population data (:mod:pycensus.taiwan.api) is real, keyless, and verified (see that module's docstring). Boundary geometry (:mod:pycensus.taiwan.geography) is implemented for county_city (geoBoundaries.org's real Taiwan ADM1 layer), district (geoBoundaries' real Taiwan ADM2 layer, matched to MOI RIS's district_code join key -- see :data:pycensus.taiwan.constants.GEOBOUNDARIES_ADM2_TO_DISTRICT_CODE for the verified derivation), and village (OpenStreetMap Overpass admin_level=9 relations, whose nat_ref tag IS MOI's own district_code -- verified against MOI's live village list on every fetch, see :mod:pycensus.taiwan.geography module docstring). NLSC's own official boundary files are cataloged real but their actual downloads are blocked by an HTTP 403 from TGOS, their file host (verified 2026-08-20), which is why geography uses these alternative real sources instead. :func:load works end-to-end for county_city, district, and village (pass explicit regions= for village -- there's no AOI auto-detection at that level yet, see regions below); nation still raises once it reaches :func:pycensus.taiwan.geography.load_boundaries -- expected and correct, not a bug: it fails loudly rather than fabricating geometry. (Aggregate county_city-level population up to a national total in Python if needed -- :func:_aggregate_to_level supports it -- rather than through a nation-level geometry fetch, since no single-polygon national outline is verified/wired up here.)

under18Population/adultPopulation/over65Population/ medianAge are computed from ODRP014's 101 real single-year-age buckets (:data:pycensus.census.countries.taiwan.api.AGE_BUCKET_SUFFIXES, top-coded at 100up). The three population splits are simple sums of age buckets and are additive across levels like any other count. medianAge is not additive -- averaging village-level medians would be wrong -- so it is instead computed once per requested level, after the age-bucket counts are themselves summed to that level (see :func:_add_derived_age_columns), directly from that level's own summed age distribution. Live-verified 2026-08-22: Taipei City's 202 age-bucket columns sum exactly to ODRP013's people_total for Taipei (2,451,007, no discrepancy), and Taipei's resulting over-65 share is 23.7% (580,555 / 2,451,007) -- plausible against Taipei's well-documented, unusually old age structure (Taiwan crossed the 20%-"super-aged" threshold nationwide in 2025; Taipei's elderly share has been running several points above the national figure for years).

Source

MOI RIS ODRP013: https://www.ris.gov.tw/rs-opendata/api/v1/datastore/ODRP013/{yyymm}

load(aoi=None, regions=None, level='county_city', year='latest', api_key=None, cache_dir=None, cache=True, data_dir=None)

Load MOI RIS resident population data as a common-schema GeoDataFrame.

Parameters:

Name Type Description Default
aoi Optional[GeoDataFrame]

Area of interest. Used to auto-detect regions if regions isn't given: at county_city level via :func:pycensus.taiwan.geography.counties_in_aoi, at district level via :func:pycensus.taiwan.geography.districts_in_aoi, and at village level via :func:pycensus.taiwan.geography.villages_in_aoi (all three have real boundary geometry, see :mod:pycensus.taiwan.geography).

None
regions Optional[Union[str, List[str]]]

Region code(s) matching level -- a 5-digit county/city code, 8-digit district code, or 11-digit village code (see :data:pycensus.taiwan.constants.COUNTY_CODES). regions is required today (see aoi above).

None
level str

Standard geometry level name. Taiwan supports nation, county_city, district, village directly; other standard levels fall back via :data:pycensus.taiwan.constants.LEVEL_FALLBACK.

'county_city'
year Union[int, str]

ROC yyymm (e.g. "11407"), or "latest" to use :data:pycensus.taiwan.constants.LATEST_YEAR.

'latest'
api_key Optional[str]

Not used -- MOI RIS's open-data API requires no API key.

None
cache_dir Optional[str]

Root of pyCensus' parquet cache. Defaults to :func:pycensus.cache.default_cache_dir.

None
cache bool

If False, bypass the parquet cache entirely.

True
data_dir Optional[str]

Root directory for raw MOI downloads (separate from cache_dir). Defaults to :data:pycensus.taiwan.constants.DEFAULT_DATA_DIR.

None

Returns:

Type Description
GeoDataFrame

GeoDataFrame with GEOID, geometry, and one moi_-prefixed

GeoDataFrame

column per logical column in :data:pycensus.taiwan.moi.schema.SCHEMA.

Raises:

Type Description
ValueError

If neither regions nor aoi is given.

NotImplementedError

If aoi is given without explicit regions at the nation level -- there's no boundary geometry to resolve an AOI against there (see :data:pycensus.taiwan.geography.IMPLEMENTED_LEVELS). county_city, district, and village all support AOI auto-detection.

download_census_data(yyymm=None, data_dir=None, overwrite=False)

Force a fresh download of MOI RIS's village-level population table to the raw cache.

Parameters:

Name Type Description Default
yyymm Optional[str]

ROC year-month. Defaults to :data:pycensus.taiwan.constants.LATEST_YEAR.

None
data_dir Optional[str]

Root directory for raw downloads.

None
overwrite bool

If True, delete the cached raw JSON file first so it is re-downloaded from MOI.

False

Returns:

Type Description
str

Path to the raw cache file that was downloaded/refreshed.