fied.geocoder package¶
Submodules¶
fied.geocoder.geo_tools module¶
- fix_county_fips(df)[source]¶
County FIPS should be strings. Use geoID or censusBlock to replace existing county FIPS.
- Parameters:
df (pandas.DataFrame) – DataFrame with either geoID or censusBlock in the columns
- Returns:
df – DataFrame with updated countyFIPS
- Return type:
pandas.DataFrame
- find_missing_congress(df)[source]¶
” Update Congressional Districts to 118th Congress, for 2020. Update the FRS column legislativeDistrictNumber
- fcc_block_api(lat_lon, census_year=2020)[source]¶
Call FCC’s Area API (https://geo.fcc.gov/api/census/) with lat, lon coordinates to return the corresponding Census Block.
- get_blocks_parallelized(df)[source]¶
Paraellization for FCC API. Final industrial data has ~360,000 unique lat, lon coordinates.
- Parameters:
df (pandas.DataFrame) – Final foundational energy dataframe
- Returns:
df – Final foundational energy dataframe with new colum for censusBlock
- Return type:
pandas.DataFrame
fied.geocoder.geopandas_tools module¶
- class FiedGIS[source]¶
Bases:
object
- static get_shapefile(year=None, state_fips=None, ftype=None)[source]¶
Get Census block group TIGER/Line shapefile for specified year and state FIPS code, or get USGS HUC geodatabase.
- Parameters:
- Returns:
gf – gf
- Return type:
geopandas.DataFrame
- static merge_coordinates_geom(fied_state, gf, ftype=None, data_source='fied')[source]¶
” First creates POINT geometry from facility coordinates. Then locates the points within specific geographic identifier type. Finally, merges geographic identifier with facility DataFrame.
- Parameters:
fied_state (pandas.DataFrame) – DataFrame of foundational data by state
gf (geopandas) – Shapefile containing Census tracts
ftype (str, {'BG', 'CD', 'COUNTY', 'HUC'}) – Type of file to return. ‘BG’ == census block groups; ‘CD’ == congressional districts; ‘COUNTY’ == county FIPS; ‘HUC’ == hydrolic unit code.
data_source (str, {'fied', 'ghgrp'}) – Source of data with missing geographic identifiers.
- Returns:
matched_geo – Geographic identifiers matched to facility coordinates.
- Return type:
pandas.DataFrame
- merge_geom(df, year=None, ftypes=['BG', 'CD'], data_source='fied')[source]¶
Pulls together methods for creating Geopandas DataFrames from geographic information files and merges geographic identifiers with the foundational data set.
- Parameters:
df (pandas.DataFrame) – DataFrame with missing geographic data.
year (int) – Year of foundational energy data.
ftype (list; default=['BG', 'CD']) – Type of missing geo data to fill in.
data_source (str, {'fied', 'ghgrp'}) – Source of missing geographic data. Used to specify columns in dataframe to use.
- Returns:
new_fied – New foundational dataset with new columns for geographic identifiers.
- Return type:
pandas.DataFrame