Commit ec9196f6 authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Forced variable types in OBM_buildings_per_cell and GDE_TOOLS_psql

parent 77ba5160
......@@ -75,7 +75,7 @@ def retrieve_parameters_of_buildings_in_cell_raw(db_name, db_username, sch_name,
conn.set_session(autocommit=True)
cur = conn.cursor() # Open a cursor to perform database operations
aux_query_str= ','.join(parameter_names)
cur.execute('SELECT %s FROM %s.%s WHERE cell_id=%s;' %(aux_query_str, sch_name, table_name, in_cell_id))
cur.execute("SELECT %s FROM %s.%s WHERE cell_id='%s';" %(aux_query_str, sch_name, table_name, in_cell_id))
exec_result = cur.fetchall()
conn.close()
return exec_result
......
......@@ -87,14 +87,14 @@ def run_this_file(config_dict):
for i, grid_cell_id in enumerate(grid_cells_list):
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='')
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= 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= 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)
for case in occupancy_cases:
if case in np.unique(bdgs_df_i['Occup_Case'].values):
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
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)
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)
if out_str!='':
log.append('Cell ID '+str(grid_cell_id)+', '+case+': '+out_str)
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