Commit 77ba5160 authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Forced variable types (2) in OBM_buildings_per_cell.py

parent 0d7965c6
...@@ -87,14 +87,14 @@ def run_this_file(config_dict): ...@@ -87,14 +87,14 @@ def run_this_file(config_dict):
for i, grid_cell_id in enumerate(grid_cells_list): for i, grid_cell_id in enumerate(grid_cells_list):
if int(grid_cell_id) > min_grid_cell_id: if int(grid_cell_id) > min_grid_cell_id:
print('\r Working on cell ID '+str(grid_cell_id)+'. Cell '+str(i+1)+' of '+str(len(grid_cells_list))+'.', end='') print('\r Working on cell ID '+str(grid_cell_id)+'. Cell '+str(i+1)+' of '+str(len(grid_cells_list))+'.', end='')
bdgs_df_i= gdet_psql.retrieve_parameters_of_buildings_in_cell_as_pandas(DB_name_bdgs, DB_username_bdgs, DB_schema_name_bdgs, DB_table_name_bdgs, grid_cell_id, parameter_names=['osm_id', 'gem_occupancy', 'building_levels', 'way_area', 'country_iso2', 'res_adm_id', 'res_adm_level', 'com_adm_id', 'com_adm_level', 'ind_adm_id', 'ind_adm_level'], get_centroid_coords=True) bdgs_df_i= gdet_psql.retrieve_parameters_of_buildings_in_cell_as_pandas(DB_name_bdgs, DB_username_bdgs, DB_schema_name_bdgs, DB_table_name_bdgs, str(grid_cell_id), parameter_names=['osm_id', 'gem_occupancy', 'building_levels', 'way_area', 'country_iso2', 'res_adm_id', 'res_adm_level', 'com_adm_id', 'com_adm_level', 'ind_adm_id', 'ind_adm_level'], get_centroid_coords=True)
bdgs_df_i= bdgs_df_i.rename(columns={'way_area': 'area', 'ST_X(ST_Transform(ST_Centroid(way),4326))': 'lon', 'ST_Y(ST_Transform(ST_Centroid(way),4326))': 'lat'}) bdgs_df_i= bdgs_df_i.rename(columns={'way_area': 'area', 'ST_X(ST_Transform(ST_Centroid(way),4326))': 'lon', 'ST_Y(ST_Transform(ST_Centroid(way),4326))': 'lat'})
bdgs_df_i= gdet_gral.add_occupancy_broad_cases(bdgs_df_i, occup_keys) bdgs_df_i= gdet_gral.add_occupancy_broad_cases(bdgs_df_i, occup_keys)
for case in occupancy_cases: for case in occupancy_cases:
if case in np.unique(bdgs_df_i['Occup_Case'].values): if case in np.unique(bdgs_df_i['Occup_Case'].values):
bdgs_df_i_case= bdgs_df_i[bdgs_df_i.Occup_Case==case] bdgs_df_i_case= bdgs_df_i[bdgs_df_i.Occup_Case==case]
if bdgs_df_i_case.shape[0]>0: # it should be redundant with the "if case in ..." condition if bdgs_df_i_case.shape[0]>0: # it should be redundant with the "if case in ..." condition
out_str= gdet_gral.write_bdgs_to_cell_hdf(bdgs_df_i_case, grid_cell_id, case, os.path.join(out_path, 'OBM_bdgs_in_cells'), sera_disaggregation_to_consider, out_path) out_str= gdet_gral.write_bdgs_to_cell_hdf(bdgs_df_i_case, str(grid_cell_id), case, os.path.join(out_path, 'OBM_bdgs_in_cells'), sera_disaggregation_to_consider, out_path)
if out_str!='': if out_str!='':
log.append('Cell ID '+str(grid_cell_id)+', '+case+': '+out_str) log.append('Cell ID '+str(grid_cell_id)+', '+case+': '+out_str)
print('\n') print('\n')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment