diff --git a/hydromt_fiat/data/attribute_linking/NSI_attributes_to_FIAT.json b/hydromt_fiat/data/attribute_linking/NSI_attributes_to_FIAT.json index 62f976b7..411b0e40 100644 --- a/hydromt_fiat/data/attribute_linking/NSI_attributes_to_FIAT.json +++ b/hydromt_fiat/data/attribute_linking/NSI_attributes_to_FIAT.json @@ -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" } \ No newline at end of file diff --git a/hydromt_fiat/fiat.py b/hydromt_fiat/fiat.py index c39e0174..b07cc114 100644 --- a/hydromt_fiat/fiat.py +++ b/hydromt_fiat/fiat.py @@ -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], @@ -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 diff --git a/hydromt_fiat/workflows/equity_data.py b/hydromt_fiat/workflows/equity_data.py index 98cb5bcd..3d3eb078 100644 --- a/hydromt_fiat/workflows/equity_data.py +++ b/hydromt_fiat/workflows/equity_data.py @@ -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) @@ -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" - ) \ No newline at end of file + ) + + 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"]] \ No newline at end of file