Skip to content

pycensus.remainder

Complete a partial fine census level with the remainders of the coarser level that contains it.

Where a fine level only covers part of the land (Israel's statistical areas exist only in the larger localities), each coarse polygon (the locality) minus the union of its fine polygons becomes a "remainder" polygon whose counts are the coarse counts minus the sum of its fine polygons' (never below 0); rates and other non-count columns keep the coarse polygon's value. A coarse polygon without any fine polygon becomes a remainder whole.

from pycensus.remainder import add_remainders
complete = add_remainders(stat_areas, localities, count_cols=["population", ...])

add_remainders(fine, coarse, count_cols, id_col='GEOID', min_area_share=0.001, suffix='_rest', flag_col='is_remainder')

fine plus one remainder polygon per coarse polygon (see the module docstring).

Each fine polygon belongs to the coarse polygon that contains its representative point. A remainder smaller than min_area_share of its coarse polygon is dropped (slivers from boundary mismatches) unless it still holds people. The remainder's id is <coarse id><suffix>; flag_col (if given) marks remainders True.

Parameters:

Name Type Description Default
fine GeoDataFrame

Fine polygons with counts.

required
coarse GeoDataFrame

Coarse polygons with the same counts.

required
count_cols Iterable[str]

Count columns.

required
id_col str

Id column.

'GEOID'
min_area_share float

Smallest remainder kept (share of its coarse polygon).

0.001
suffix str

Suffix of the remainder ids.

'_rest'
flag_col Optional[str]

Column marking the remainders.

'is_remainder'