Skip to content

Commit

Permalink
aligning with floodadapt needs
Browse files Browse the repository at this point in the history
  • Loading branch information
frederique-hub committed Dec 13, 2023
1 parent 09183af commit 1b002c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"Ground Floor Height": "found_ht",
"Ground Elevation": "ground_elv",
"geometry": "geometry",
"Aggregation Label: Census Block": "cbfips"
"Aggregation Label: Census Blockgroup": "cbfips"
}
7 changes: 6 additions & 1 deletion hydromt_fiat/fiat.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,9 +757,13 @@ def setup_equity_data(
equity.match_geo_ID()
equity.download_shp_geom(year_data, county_numbers)
equity.merge_equity_data_shp()
equity.clean()

self.set_tables(df=equity.equity_data_shp, name="equity_data")

# Update (if necessary) the aggregation label: census block
# Save the census block aggregation area data

def setup_aggregation_areas(
self,
aggregation_area_fn: Union[List[str], List[Path], str, Path],
Expand All @@ -779,7 +783,8 @@ def setup_aggregation_areas(
label_names : Union[List[str], str]
The name that the new attribute will get in the exposure data.
"""

# TODO: add a census block option to automatically download and save
# the data
exposure_gdf = self.exposure.get_full_gdf(self.exposure.exposure_db)
self.exposure.exposure_db = join_exposure_aggregation_areas(
exposure_gdf, aggregation_area_fn, attribute_names, label_names
Expand Down
11 changes: 8 additions & 3 deletions hydromt_fiat/workflows/equity_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def download_shp_geom(self, year_data: int, counties: List[str]):

block_groups_shp = shp.dissolve(by=attrs, as_index=False)
block_groups_shp = block_groups_shp[attrs + ["geometry"]]
# block_groups["Census_Bg"] = block_groups['TRACTCE' + code].astype(str) + "-block" + block_groups['BLKGRPCE' + code].astype(str)
block_groups_shp["GEOID_short"] = block_groups_shp['STATEFP' + code].astype(str) + block_groups_shp['COUNTYFP' + code].astype(str) + block_groups_shp['TRACTCE' + code].astype(str) + block_groups_shp['BLKGRPCE' + code].astype(str)
block_groups_shp["GEO_ID"] = "1500000US" + block_groups_shp['STATEFP' + code].astype(str) + block_groups_shp['COUNTYFP' + code].astype(str) + block_groups_shp['TRACTCE' + code].astype(str) + block_groups_shp['BLKGRPCE' + code].astype(str)
block_groups_list.append(block_groups_shp)

Expand All @@ -191,8 +191,13 @@ def merge_equity_data_shp(self):
# Delete the rows that do not have a geometry column
self.equity_data_shp = self.equity_data_shp.loc[self.equity_data_shp["geometry"].notnull()]

#self.svi_data_shp.drop(columns=columns_to_drop, inplace=True)
self.equity_data_shp = self.equity_data_shp.to_crs(epsg=4326)
self.logger.info(
"The geometry information was successfully added to the equity information"
)
)

aggregation_areas = self.block_groups[["GEOID_short", "geometry"]]

def clean(self):
"""Removes unnecessary columns"""
self.svi_data_shp = self.svi_data_shp[["GEOID_short", "TotalPopulationBG", "PerCapitaIncomeBG"]]

0 comments on commit 1b002c4

Please sign in to comment.