epymorph.geography.us_census
Geo scope instances that utilize US Census delineations.
Generally, each CensusScope
describes the granularity of the nodes
in scope, plus some containing boundary at the same level of granularity
or higher in which all nodes in that boundary are considered in scope.
For instance, "give me all of the counties in Nebraska and South Dakota".
CensusScopeT
module-attribute
CensusScopeT = TypeVar('CensusScopeT', bound=CensusScope)
The type of geo scope.
CensusSelectionT
module-attribute
CensusSelectionT = TypeVar(
"CensusSelectionT",
bound=StateSelection
| CountySelection
| TractSelection
| BlockGroupSelection,
)
The type of geo selection.
CensusScope
dataclass
CensusScope(
year: int,
granularity: CensusGranularityName,
includes_granularity: CensusGranularityName,
includes: tuple[str, ...],
)
Base class for geo scopes using US Census delineations.
year
instance-attribute
year: int
The Census delineation year. Census Bureau can (and does) define new delineations annually, especially at the smaller granularities. Hence, you must know the year in order to absolutely identify a set of delineations.
granularity
instance-attribute
granularity: CensusGranularityName
Which granularity are the nodes in this scope?
includes_granularity
instance-attribute
includes_granularity: CensusGranularityName
Which granularity defines the bounds of this scope?
includes
instance-attribute
Which nodes (of includes_granularity
) are in scope?
raise_granularity
abstractmethod
raise_granularity() -> CensusScope
Returns:
-
CensusScope
–A scope with granularity one level higher than this. This may have the effect of widening the scope; for example, raising a
TractScope
which is filtered to a set of tracts will result in aCountyScope
containing the counties that contained our tracts.
Raises:
-
GeographyError
–If the granularity cannot be raised.
lower_granularity
abstractmethod
lower_granularity() -> CensusScope
Returns:
-
CensusScope
–A scope with granularity one level lower than this.
Raises:
-
GeographyError
–If the granularity cannot be lowered.
as_granularity
as_granularity(
granularity: CensusGranularityName,
) -> CensusScope
Returns:
-
CensusScope
–A scope of the named granularity by either raising or lowering the original scope to match. If
granularity
already matches this scope, it is returned unchanged.
Raises:
-
GeographyError
–If the granularity cannot be modified as requested.
of
staticmethod
of(
name: CensusGranularityName,
node_ids: Sequence[str],
year: int,
) -> CensusScope
Creates a CensusScope
instance of the named granularity,
using nodes IDs of the same granularity. This is the same as
StateScope.in_states(...)
for example.
Parameters:
-
name
(CensusGranularityName
) –The name of the Census granularity for the resulting scope.
-
node_ids
(Sequence[str]
) –The node IDs to include in the scope; these IDs must identify nodes of the same granularity as
name
. -
year
(int
) –The Census delineation year.
get_info
abstractmethod
get_info() -> DataFrame
Retrieve TIGER info for the nodes in this scope. This is very similar to the
geography
property of CensusScope
s, but it omits the shape data so it's a
little faster for use-cases that don't need it.
StateScope
dataclass
StateScope(
year: int,
granularity: CensusGranularityName,
includes_granularity: Literal["state"],
includes: tuple[str, ...],
)
Bases: _InStatesMixin
, CensusScope
A CensusScope
at the US State granularity.
Typically you'll create one of these using all
or in_states
.
Parameters:
-
year
(int
) –The Census delineation year.
-
includes_granularity
(Literal['state']
) –Which granularity defines the bounds of this scope?
-
includes
(tuple[str, ...]
) –Which nodes (of
includes_granularity
) are in scope?
year
instance-attribute
year: int
The Census delineation year. Census Bureau can (and does) define new delineations annually, especially at the smaller granularities. Hence, you must know the year in order to absolutely identify a set of delineations.
includes_granularity
instance-attribute
includes_granularity: Literal['state']
Which granularity defines the bounds of this scope?
includes
instance-attribute
Which nodes (of includes_granularity
) are in scope?
granularity
class-attribute
instance-attribute
Which granularity are the nodes in this scope?
select
property
select: StateSelector[StateScope, StateSelection]
Create a selection from this scope.
labels_option
property
An optional text label for each node. If this returns None
,
convention is to use the node IDs as the labels.
geography
cached
property
geography: GeoDataFrame
Retrieves the shapes corresponding to the nodes of this scope as a
GeoDataFrame
. Note that this is not possible for all types of GeoScope
.
Returns:
-
GeoDataFrame | Never
–The geography.
Raises:
-
GeographyError
–If we cannot fetch geography for this type of scope.
all
classmethod
is_all_states
is_all_states() -> bool
Returns:
-
bool
–True if this scope includes all supported US states.
raise_granularity
raise_granularity() -> Never
Returns:
-
CensusScope
–A scope with granularity one level higher than this. This may have the effect of widening the scope; for example, raising a
TractScope
which is filtered to a set of tracts will result in aCountyScope
containing the counties that contained our tracts.
Raises:
-
GeographyError
–If the granularity cannot be raised.
lower_granularity
lower_granularity() -> CountyScope
Returns:
-
CensusScope
–A scope with granularity one level lower than this.
Raises:
-
GeographyError
–If the granularity cannot be lowered.
get_info
get_info() -> DataFrame
Retrieve TIGER info for the nodes in this scope. This is very similar to the
geography
property of CensusScope
s, but it omits the shape data so it's a
little faster for use-cases that don't need it.
in_states
classmethod
Create a scope including all nodes in a set of US states/state-equivalents.
Parameters:
-
states
(Sequence[str]
) –The set of states to include. This can be a list of either state names, postal codes, or FIPs codes.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
states
is invalid.
CountyScope
dataclass
CountyScope(
year: int,
granularity: CensusGranularityName,
includes_granularity: Literal["state", "county"],
includes: tuple[str, ...],
)
Bases: _InStatesMixin
, _InCountiesMixin
, CensusScope
A CensusScope
at the US County granularity.
Typically you'll create one of these using all
, in_states
, or in_counties
.
Parameters:
-
year
(int
) –The Census delineation year.
-
includes_granularity
(Literal['state', 'county']
) –Which granularity defines the bounds of this scope?
-
includes
(tuple[str, ...]
) –Which nodes (of
includes_granularity
) are in scope?
year
instance-attribute
year: int
The Census delineation year. Census Bureau can (and does) define new delineations annually, especially at the smaller granularities. Hence, you must know the year in order to absolutely identify a set of delineations.
includes_granularity
instance-attribute
includes_granularity: Literal['state', 'county']
Which granularity defines the bounds of this scope?
includes
instance-attribute
Which nodes (of includes_granularity
) are in scope?
granularity
class-attribute
instance-attribute
Which granularity are the nodes in this scope?
select
property
select: CountySelector[CountyScope, CountySelection]
Create a selection from this scope.
labels_option
property
An optional text label for each node. If this returns None
,
convention is to use the node IDs as the labels.
geography
cached
property
geography: GeoDataFrame
Retrieves the shapes corresponding to the nodes of this scope as a
GeoDataFrame
. Note that this is not possible for all types of GeoScope
.
Returns:
-
GeoDataFrame | Never
–The geography.
Raises:
-
GeographyError
–If we cannot fetch geography for this type of scope.
all
classmethod
raise_granularity
raise_granularity() -> StateScope
Returns:
-
CensusScope
–A scope with granularity one level higher than this. This may have the effect of widening the scope; for example, raising a
TractScope
which is filtered to a set of tracts will result in aCountyScope
containing the counties that contained our tracts.
Raises:
-
GeographyError
–If the granularity cannot be raised.
lower_granularity
lower_granularity() -> TractScope
Returns:
-
CensusScope
–A scope with granularity one level lower than this.
Raises:
-
GeographyError
–If the granularity cannot be lowered.
get_info
get_info() -> DataFrame
Retrieve TIGER info for the nodes in this scope. This is very similar to the
geography
property of CensusScope
s, but it omits the shape data so it's a
little faster for use-cases that don't need it.
in_counties
classmethod
Create a scope including all nodes in a set of US counties/county-equivalents.
Parameters:
-
counties
(Sequence[str]
) –The set of counties to include. This can be a list of county names (in county-comma-postal-code format, e.g., "Maricopa, AZ") or FIPS codes.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
counties
is invalid.
in_states
classmethod
Create a scope including all nodes in a set of US states/state-equivalents.
Parameters:
-
states
(Sequence[str]
) –The set of states to include. This can be a list of either state names, postal codes, or FIPs codes.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
states
is invalid.
TractScope
dataclass
TractScope(
year: int,
granularity: CensusGranularityName,
includes_granularity: Literal[
"state", "county", "tract"
],
includes: tuple[str, ...],
)
Bases: _InStatesMixin
, _InCountiesMixin
, _InTractsMixin
, CensusScope
A CensusScope
at the US Tract granularity.
Typically you will create one of these using in_states
, in_counties
, or
in_tracts
.
Parameters:
-
year
(int
) –The Census delineation year.
-
includes_granularity
(Literal['state', 'county', 'tract']
) –Which granularity defines the bounds of this scope?
-
includes
(tuple[str, ...]
) –Which nodes (of
includes_granularity
) are in scope?
year
instance-attribute
year: int
The Census delineation year. Census Bureau can (and does) define new delineations annually, especially at the smaller granularities. Hence, you must know the year in order to absolutely identify a set of delineations.
includes_granularity
instance-attribute
includes_granularity: Literal['state', 'county', 'tract']
Which granularity defines the bounds of this scope?
includes
instance-attribute
Which nodes (of includes_granularity
) are in scope?
granularity
class-attribute
instance-attribute
Which granularity are the nodes in this scope?
select
property
select: TractSelector[TractScope, TractSelection]
Create a selection from this scope.
geography
cached
property
geography: GeoDataFrame
Retrieves the shapes corresponding to the nodes of this scope as a
GeoDataFrame
. Note that this is not possible for all types of GeoScope
.
Returns:
-
GeoDataFrame | Never
–The geography.
Raises:
-
GeographyError
–If we cannot fetch geography for this type of scope.
raise_granularity
raise_granularity() -> CountyScope
Returns:
-
CensusScope
–A scope with granularity one level higher than this. This may have the effect of widening the scope; for example, raising a
TractScope
which is filtered to a set of tracts will result in aCountyScope
containing the counties that contained our tracts.
Raises:
-
GeographyError
–If the granularity cannot be raised.
lower_granularity
lower_granularity() -> BlockGroupScope
Returns:
-
CensusScope
–A scope with granularity one level lower than this.
Raises:
-
GeographyError
–If the granularity cannot be lowered.
get_info
get_info() -> DataFrame
Retrieve TIGER info for the nodes in this scope. This is very similar to the
geography
property of CensusScope
s, but it omits the shape data so it's a
little faster for use-cases that don't need it.
in_tracts
classmethod
Create a scope including all nodes in a set of US Census tracts.
Parameters:
-
tracts
(Sequence[str]
) –The set of tracts to include, by ID.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
tracts
is invalid.
in_counties
classmethod
Create a scope including all nodes in a set of US counties/county-equivalents.
Parameters:
-
counties
(Sequence[str]
) –The set of counties to include. This can be a list of county names (in county-comma-postal-code format, e.g., "Maricopa, AZ") or FIPS codes.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
counties
is invalid.
in_states
classmethod
Create a scope including all nodes in a set of US states/state-equivalents.
Parameters:
-
states
(Sequence[str]
) –The set of states to include. This can be a list of either state names, postal codes, or FIPs codes.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
states
is invalid.
BlockGroupScope
dataclass
BlockGroupScope(
year: int,
granularity: CensusGranularityName,
includes_granularity: Literal[
"state", "county", "tract", "block group"
],
includes: tuple[str, ...],
)
Bases: _InStatesMixin
, _InCountiesMixin
, _InTractsMixin
, _InBlockGroupsMixin
, CensusScope
A CensusScope
at the US Block Group granularity.
Typically you will create one of these using in_states
, in_counties
,
in_tracts
, or in_block_groups
.
Parameters:
-
year
(int
) –The Census delineation year.
-
includes_granularity
(Literal['state', 'county', 'tract', 'block group']
) –Which granularity defines the bounds of this scope?
-
includes
(tuple[str, ...]
) –Which nodes (of
includes_granularity
) are in scope?
year
instance-attribute
year: int
The Census delineation year. Census Bureau can (and does) define new delineations annually, especially at the smaller granularities. Hence, you must know the year in order to absolutely identify a set of delineations.
includes_granularity
instance-attribute
includes_granularity: Literal[
"state", "county", "tract", "block group"
]
Which granularity defines the bounds of this scope?
includes
instance-attribute
Which nodes (of includes_granularity
) are in scope?
granularity
class-attribute
instance-attribute
Which granularity are the nodes in this scope?
select
property
select: BlockGroupSelector[
BlockGroupScope, BlockGroupSelection
]
Create a selection from this scope.
geography
cached
property
geography: GeoDataFrame
Retrieves the shapes corresponding to the nodes of this scope as a
GeoDataFrame
. Note that this is not possible for all types of GeoScope
.
Returns:
-
GeoDataFrame | Never
–The geography.
Raises:
-
GeographyError
–If we cannot fetch geography for this type of scope.
raise_granularity
raise_granularity() -> TractScope
Returns:
-
CensusScope
–A scope with granularity one level higher than this. This may have the effect of widening the scope; for example, raising a
TractScope
which is filtered to a set of tracts will result in aCountyScope
containing the counties that contained our tracts.
Raises:
-
GeographyError
–If the granularity cannot be raised.
lower_granularity
lower_granularity() -> Never
Returns:
-
CensusScope
–A scope with granularity one level lower than this.
Raises:
-
GeographyError
–If the granularity cannot be lowered.
get_info
get_info() -> DataFrame
Retrieve TIGER info for the nodes in this scope. This is very similar to the
geography
property of CensusScope
s, but it omits the shape data so it's a
little faster for use-cases that don't need it.
in_block_groups
classmethod
Create a scope including all nodes in a set of US Census block groups.
Parameters:
-
block_groups
(Sequence[str]
) –The set of block groups to include, by ID.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
block_groups
is invalid.
in_tracts
classmethod
Create a scope including all nodes in a set of US Census tracts.
Parameters:
-
tracts
(Sequence[str]
) –The set of tracts to include, by ID.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
tracts
is invalid.
in_counties
classmethod
Create a scope including all nodes in a set of US counties/county-equivalents.
Parameters:
-
counties
(Sequence[str]
) –The set of counties to include. This can be a list of county names (in county-comma-postal-code format, e.g., "Maricopa, AZ") or FIPS codes.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
counties
is invalid.
in_states
classmethod
Create a scope including all nodes in a set of US states/state-equivalents.
Parameters:
-
states
(Sequence[str]
) –The set of states to include. This can be a list of either state names, postal codes, or FIPs codes.
-
year
(int
) –The Census delineation year.
Returns:
-
Self
–The new scope.
Raises:
-
GeographyError
–If the year or any entry in
states
is invalid.
CensusGrouping
dataclass
CensusGrouping(granularity: CensusGranularityName)
Bases: GeoGrouping
A geo-axis grouping for Census geo scopes, for example, "group by state".
Parameters:
-
granularity
(CensusGranularityName
) –The granularity to group by.
map
Produce a column that describes the group membership of each node.
The returned column will be used as the basis of a groupby
operation.
Parameters:
Returns:
StateSelection
dataclass
StateSelection(
scope: GeoScopeT_co,
selection: NDArray[bool_],
grouping: GeoGrouping | None,
aggregation: GeoAggMethod | None,
)
CountySelection
dataclass
CountySelection(
scope: GeoScopeT_co,
selection: NDArray[bool_],
grouping: GeoGrouping | None,
aggregation: GeoAggMethod | None,
)
Bases: GeoSelection[CensusScope]
A geo selection on a CountyScope
.
group
group(
grouping: Literal["state"] | GeoGrouping,
) -> GeoGroup[CensusScope]
Groups the geo series using the specified grouping.
Parameters:
-
grouping
(Literal['state'] | GeoGrouping
) –The grouping to use. You can specify a supported string value -- all of which act as shortcuts for common
GeoGrouping
instances -- or you can provide aGeoGrouping
instance to perform custom grouping.The shortcut values are:
- "state": equivalent to
CensusGrouping("state")
- "state": equivalent to
Returns:
-
GeoGroup[CensusScope]
–The group strategy.
TractSelection
dataclass
TractSelection(
scope: GeoScopeT_co,
selection: NDArray[bool_],
grouping: GeoGrouping | None,
aggregation: GeoAggMethod | None,
)
Bases: GeoSelection[CensusScope]
A geo selection on a TractScope
.
group
group(
grouping: Literal["state", "county"] | GeoGrouping,
) -> GeoGroup[CensusScope]
Groups the geo series using the specified grouping.
Parameters:
-
grouping
(Literal['state', 'county'] | GeoGrouping
) –The grouping to use. You can specify a supported string value -- all of which act as shortcuts for common
GeoGrouping
instances -- or you can provide aGeoGrouping
instance to perform custom grouping.The shortcut values are:
- "state": equivalent to
CensusGrouping("state")
- "county": equivalent to
CensusGrouping("county")
- "state": equivalent to
Returns:
-
GeoGroup[CensusScope]
–The group strategy.
BlockGroupSelection
dataclass
BlockGroupSelection(
scope: GeoScopeT_co,
selection: NDArray[bool_],
grouping: GeoGrouping | None,
aggregation: GeoAggMethod | None,
)
Bases: GeoSelection[CensusScope]
A geo selection on a BlockGroupScope
.
group
group(
grouping: Literal["state", "county", "tract"]
| GeoGrouping,
) -> GeoGroup[CensusScope]
Groups the geo series using the specified grouping.
Parameters:
-
grouping
(Literal['state', 'county', 'tract'] | GeoGrouping
) –The grouping to use. You can specify a supported string value -- all of which act as shortcuts for common
GeoGrouping
instances -- or you can provide aGeoGrouping
instance to perform custom grouping.The shortcut values are:
- "state": equivalent to
CensusGrouping("state")
- "county": equivalent to
CensusGrouping("county")
- "tract": equivalent to
CensusGrouping("tract")
- "state": equivalent to
StateSelector
dataclass
StateSelector(
_scope: CensusScopeT,
_selection_class: type[CensusSelectionT],
)
Bases: _CensusSelector[CensusScopeT, CensusSelectionT]
A geo selector on a StateScope
.
Most of the time you obtain one of these using a scope's select
property.
by_state
by_state(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of states.
Parameters:
-
*identifiers
(str
, default:()
) –The set of states to include, as var-args. This can be a list of either state names, postal codes, or FIPs codes.
Returns:
-
CensusSelectionT
–The geo selection.
by_geoid
by_geoid(*geoids: str) -> CensusSelectionT
Select nodes by GEOID. It is possible to select all nodes within a coarser granularity by passing those GEOIDs, however all GEOIDs given must be the same granularity.
Parameters:
-
*geoids
(str
, default:()
) –The GEOIDs to select, as var-args.
Returns:
-
CensusSelectionT
–The geo selection.
by_slice
by_slice(
start: int,
stop: int | None = None,
step: int | None = None,
) -> CensusSelectionT
Select nodes by specifying a slice on the node indices.
Parameters:
-
start
(int
) –The initial index.
-
stop
(int | None
, default:None
) –The stop index (exclusive of the endpoint), or
None
for no endpoint. -
step
(int | None
, default:None
) –The interval between selected indices, or
None
to default to every index.
Returns:
-
CensusSelectionT
–The geo selection.
by_indices
by_indices(indices: list[int]) -> CensusSelectionT
Select nodes by specifying the node indices to include.
Parameters:
Returns:
-
CensusSelectionT
–The geo selection.
CountySelector
dataclass
CountySelector(
_scope: CensusScopeT,
_selection_class: type[CensusSelectionT],
)
Bases: StateSelector[CensusScopeT, CensusSelectionT]
A geo selector on a CountyScope
.
Most of the time you obtain one of these using a scope's select
property.
by_county
by_county(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of counties.
Parameters:
-
*identifiers
(str
, default:()
) –The set of counties to include, as var-args. This can be a list of county names (in county-comma-postal-code format, e.g., "Maricopa, AZ") or FIPS codes.
Returns:
-
CensusSelectionT
–The geo selection.
by_geoid
by_geoid(*geoids: str) -> CensusSelectionT
Select nodes by GEOID. It is possible to select all nodes within a coarser granularity by passing those GEOIDs, however all GEOIDs given must be the same granularity.
Parameters:
-
*geoids
(str
, default:()
) –The GEOIDs to select, as var-args.
Returns:
-
CensusSelectionT
–The geo selection.
by_slice
by_slice(
start: int,
stop: int | None = None,
step: int | None = None,
) -> CensusSelectionT
Select nodes by specifying a slice on the node indices.
Parameters:
-
start
(int
) –The initial index.
-
stop
(int | None
, default:None
) –The stop index (exclusive of the endpoint), or
None
for no endpoint. -
step
(int | None
, default:None
) –The interval between selected indices, or
None
to default to every index.
Returns:
-
CensusSelectionT
–The geo selection.
by_indices
by_indices(indices: list[int]) -> CensusSelectionT
Select nodes by specifying the node indices to include.
Parameters:
Returns:
-
CensusSelectionT
–The geo selection.
by_state
by_state(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of states.
Parameters:
-
*identifiers
(str
, default:()
) –The set of states to include, as var-args. This can be a list of either state names, postal codes, or FIPs codes.
Returns:
-
CensusSelectionT
–The geo selection.
TractSelector
dataclass
TractSelector(
_scope: CensusScopeT,
_selection_class: type[CensusSelectionT],
)
Bases: CountySelector[CensusScopeT, CensusSelectionT]
A geo selector on a TractScope
.
Most of the time you obtain one of these using a scope's select
property.
by_tract
by_tract(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of tracts.
Parameters:
-
*identifiers
(str
, default:()
) –The set of tracts to include by ID, as var-args.
Returns:
-
CensusSelectionT
–The geo selection.
by_geoid
by_geoid(*geoids: str) -> CensusSelectionT
Select nodes by GEOID. It is possible to select all nodes within a coarser granularity by passing those GEOIDs, however all GEOIDs given must be the same granularity.
Parameters:
-
*geoids
(str
, default:()
) –The GEOIDs to select, as var-args.
Returns:
-
CensusSelectionT
–The geo selection.
by_slice
by_slice(
start: int,
stop: int | None = None,
step: int | None = None,
) -> CensusSelectionT
Select nodes by specifying a slice on the node indices.
Parameters:
-
start
(int
) –The initial index.
-
stop
(int | None
, default:None
) –The stop index (exclusive of the endpoint), or
None
for no endpoint. -
step
(int | None
, default:None
) –The interval between selected indices, or
None
to default to every index.
Returns:
-
CensusSelectionT
–The geo selection.
by_indices
by_indices(indices: list[int]) -> CensusSelectionT
Select nodes by specifying the node indices to include.
Parameters:
Returns:
-
CensusSelectionT
–The geo selection.
by_state
by_state(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of states.
Parameters:
-
*identifiers
(str
, default:()
) –The set of states to include, as var-args. This can be a list of either state names, postal codes, or FIPs codes.
Returns:
-
CensusSelectionT
–The geo selection.
by_county
by_county(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of counties.
Parameters:
-
*identifiers
(str
, default:()
) –The set of counties to include, as var-args. This can be a list of county names (in county-comma-postal-code format, e.g., "Maricopa, AZ") or FIPS codes.
Returns:
-
CensusSelectionT
–The geo selection.
BlockGroupSelector
dataclass
BlockGroupSelector(
_scope: CensusScopeT,
_selection_class: type[CensusSelectionT],
)
Bases: TractSelector[CensusScopeT, CensusSelectionT]
A geo selector on a BlockGroupScope
.
Most of the time you obtain one of these using a scope's select
property.
by_block_group
by_block_group(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of block groups.
Parameters:
-
*identifiers
(str
, default:()
) –The set of block groups to include by ID, as var-args.
Returns:
-
CensusSelectionT
–The geo selection.
by_geoid
by_geoid(*geoids: str) -> CensusSelectionT
Select nodes by GEOID. It is possible to select all nodes within a coarser granularity by passing those GEOIDs, however all GEOIDs given must be the same granularity.
Parameters:
-
*geoids
(str
, default:()
) –The GEOIDs to select, as var-args.
Returns:
-
CensusSelectionT
–The geo selection.
by_slice
by_slice(
start: int,
stop: int | None = None,
step: int | None = None,
) -> CensusSelectionT
Select nodes by specifying a slice on the node indices.
Parameters:
-
start
(int
) –The initial index.
-
stop
(int | None
, default:None
) –The stop index (exclusive of the endpoint), or
None
for no endpoint. -
step
(int | None
, default:None
) –The interval between selected indices, or
None
to default to every index.
Returns:
-
CensusSelectionT
–The geo selection.
by_indices
by_indices(indices: list[int]) -> CensusSelectionT
Select nodes by specifying the node indices to include.
Parameters:
Returns:
-
CensusSelectionT
–The geo selection.
by_state
by_state(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of states.
Parameters:
-
*identifiers
(str
, default:()
) –The set of states to include, as var-args. This can be a list of either state names, postal codes, or FIPs codes.
Returns:
-
CensusSelectionT
–The geo selection.
by_county
by_county(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of counties.
Parameters:
-
*identifiers
(str
, default:()
) –The set of counties to include, as var-args. This can be a list of county names (in county-comma-postal-code format, e.g., "Maricopa, AZ") or FIPS codes.
Returns:
-
CensusSelectionT
–The geo selection.
by_tract
by_tract(*identifiers: str) -> CensusSelectionT
Select all nodes within a set of tracts.
Parameters:
-
*identifiers
(str
, default:()
) –The set of tracts to include by ID, as var-args.
Returns:
-
CensusSelectionT
–The geo selection.