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 |
None
|
regions
|
Optional[Union[str, List[str]]]
|
Region code(s) matching |
None
|
level
|
str
|
Standard geometry level name. Taiwan supports |
'county_city'
|
year
|
Union[int, str]
|
ROC yyymm (e.g. |
'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: |
None
|
cache
|
bool
|
If |
True
|
data_dir
|
Optional[str]
|
Root directory for raw MOI downloads (separate from
|
None
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame with |
GeoDataFrame
|
column per logical column in :data: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
NotImplementedError
|
If |
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: |
None
|
data_dir
|
Optional[str]
|
Root directory for raw downloads. |
None
|
overwrite
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the raw cache file that was downloaded/refreshed. |