Skip to main content

Geoid

Enum Geoid 

Source
pub enum Geoid {
    State(State),
    County(State, County),
    CountySubdivision(State, County, CountySubdivision),
    Place(State, Place),
    CensusTract(State, County, CensusTract),
    BlockGroup(State, County, CensusTract, BlockGroup),
    Block(State, County, CensusTract, Block),
}

Variants§

Implementations§

Source§

impl Geoid

Source

pub fn all_states() -> Vec<Geoid>

generates all state level Geoids for the U.S.

Source

pub fn geoid_type(&self) -> GeoidType

Source

pub fn variant_name(&self) -> String

Source

pub fn truncate_geoid_to_type( &self, target: &GeoidType, ) -> Result<Geoid, String>

manipulates this GEOID via truncation to transform it’s GEOID type.

GEOID is a hierarchical numeric identifier. we can truncate the values in order to reach a higher/larger geographic representation. this method supports that operation, where this Geoid instance will be truncated to transform it into some other GeoidType.

§Examples

converts GEOID 08059009838 (TRACT) to 08059 (COUNTY).

use bamcensus_core::model::identifier::{Geoid, GeoidType, fips};
let geoid = Geoid::CensusTract(
    fips::State(8),         // 08     Colorado
    fips::County(59),       // 059    Jefferson
    fips::CensusTract(9838) // 009838
);
let result = geoid.truncate_geoid_to_type(&GeoidType::County).unwrap();
assert_eq!(result, Geoid::County(fips::State(8), fips::County(59)))
Source

pub fn is_parent_of(&self, child: &Geoid) -> bool

predicate to filter by hierarchical geoshed.

Source

pub fn to_parent(&self) -> Option<Geoid>

manipulates this GEOID via truncation to transform it’s GEOID type to that of it’s parent.

the base case is None, which is the parent of State, and signifies “no restriction” in census queries. for all other GeoidTypes, we simply remove the lowest area type.

§Note

Geoid::Block.to_parent() produces a CensusTract, not a BlockGroup, based on https://www.census.gov/programs-surveys/geography/guidance/geo-identifiers.html, which does not imply that all block groups are the first digit of all blocks.

Source

pub fn to_state(&self) -> Geoid

Source

pub fn to_state_abbreviation(&self) -> Result<String, String>

Source

pub fn to_county(&self) -> Result<Geoid, String>

Source

pub fn to_census_tract(&self) -> Result<Geoid, String>

Trait Implementations§

Source§

impl Clone for Geoid

Source§

fn clone(&self) -> Geoid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Geoid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Geoid

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Geoid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Geoid

Source§

impl HasGeoidString for Geoid

Source§

impl Hash for Geoid

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Geoid

Source§

fn eq(&self, other: &Geoid) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Geoid

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Geoid

Source§

impl TryFrom<&str> for Geoid

Source§

type Error = String

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Geoid> for StateCode

Source§

type Error = String

The type returned in the event of a conversion error.
Source§

fn try_from(value: Geoid) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Geoid

§

impl RefUnwindSafe for Geoid

§

impl Send for Geoid

§

impl Sync for Geoid

§

impl Unpin for Geoid

§

impl UnsafeUnpin for Geoid

§

impl UnwindSafe for Geoid

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.