Skip to content

pycensus.census.countries.taiwan.moi

Taiwan MOI RIS (內政部戶政司) resident population source.

Importing this module registers the gdf.moi GeoDataFrame accessor (see :mod:pycensus.accessors). Use :func:load to fetch data.

Technical aspects

MOI's household-registration statistics (dataset ODRP013) provide real, keyless, verified population/male/female counts down to village granularity -- see :mod:pycensus.taiwan.api and :mod:pycensus.taiwan.moi.loader module docstrings. Boundary geometry is not implemented for any level (see :mod:pycensus.taiwan.geography), so :func:load currently raises NotImplementedError once it reaches geometry assembly.

Source

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.

load_realprice(year, level='district', cities=('a', 'f'), data_dir=None, min_obs=1)

Median price/rent per m2 and record counts by level ('village' 11-digit, 'district' 8-digit, 'county_city' 5-digit GEOID).

year is a calendar year (2012 holds only Q3-Q4). Returns DataFrame GEOID + realPrice/realRent columns (NaN median where < min_obs).

Parameters:

Name Type Description Default
year int

Calendar year.

required
level str

"village", "district" or "county_city".

'district'
cities Iterable[str]

County letters.

('a', 'f')
data_dir Optional[str]

Folder of the raw downloads; None = the pycensus cache.

None
min_obs int

Fewest records for a median.

1