Spaces:
Sleeping
Sleeping
Commit 路
d238bb5
1
Parent(s): b87b193
Change % to pct
Browse files- app.py +1 -1
- data_utils.py +8 -8
- example.csv +1 -1
- plot_utils.py +1 -1
app.py
CHANGED
|
@@ -170,7 +170,7 @@ def server(input, output, session):
|
|
| 170 |
if simulation_mode == "Usar control deslizante":
|
| 171 |
title = f"Estimaci贸n de cobertura arb贸rea necesaria para una disminuci贸n de {value_temp}掳C"
|
| 172 |
try:
|
| 173 |
-
fig = show_two_plots(gdf_temp, '%total_trees', '
|
| 174 |
min_cobertura_veg, max_cobertura, 'YlGn',
|
| 175 |
title,"Cobertura arb贸rea antes",
|
| 176 |
"Cobertura arb贸rea (%)", split=split)
|
|
|
|
| 170 |
if simulation_mode == "Usar control deslizante":
|
| 171 |
title = f"Estimaci贸n de cobertura arb贸rea necesaria para una disminuci贸n de {value_temp}掳C"
|
| 172 |
try:
|
| 173 |
+
fig = show_two_plots(gdf_temp, '%total_trees', 'Pct_CoberturaVeg',
|
| 174 |
min_cobertura_veg, max_cobertura, 'YlGn',
|
| 175 |
title,"Cobertura arb贸rea antes",
|
| 176 |
"Cobertura arb贸rea (%)", split=split)
|
data_utils.py
CHANGED
|
@@ -9,7 +9,7 @@ headers = {"Content-Type": "application/json"}
|
|
| 9 |
|
| 10 |
cell_area = 100*100 #in square meters
|
| 11 |
|
| 12 |
-
def make_XYT(df, treatment_col = '
|
| 13 |
|
| 14 |
Y = df[target_col].values
|
| 15 |
|
|
@@ -27,7 +27,7 @@ def prepare_data(og_file):
|
|
| 27 |
original_df = original_df.round(2)
|
| 28 |
|
| 29 |
df = original_df[['Elevacion', 'Neighbor_NDBI', 'Proximidad_agua',
|
| 30 |
-
'Neighbor_%CoberturaVeg', '
|
| 31 |
df = df.astype(np.float32)
|
| 32 |
|
| 33 |
X, Y, T = make_XYT(df)
|
|
@@ -36,8 +36,8 @@ def prepare_data(og_file):
|
|
| 36 |
|
| 37 |
|
| 38 |
def prepare_treatment_df(original_df, df):
|
| 39 |
-
treatment_df = original_df[['x','y','
|
| 40 |
-
treatment_df.loc[:, '
|
| 41 |
treatment_df.loc[:, 'LST'] = df['LST'].values
|
| 42 |
|
| 43 |
treatment_df = treatment_df.reset_index()
|
|
@@ -64,7 +64,7 @@ def run_treatment_increase(X, T, original_df, df, value, name, simulation_mode):
|
|
| 64 |
|
| 65 |
treatment_df[name] = result["effect"]
|
| 66 |
treatment_df['%total_trees'] = T_sim
|
| 67 |
-
treatment_df['pp_trees_increase'] = treatment_df['%total_trees'] - treatment_df['
|
| 68 |
|
| 69 |
return treatment_df
|
| 70 |
|
|
@@ -78,7 +78,7 @@ def process_data_trees_to_temp(value, simulation_mode, original_df, df, X, Y, T)
|
|
| 78 |
treatment_df['sqm_trees_increase'] = (treatment_df['pp_trees_increase']/100)*cell_area
|
| 79 |
treatment_df['sqm_total_trees'] = (treatment_df['%total_trees']/100)*cell_area
|
| 80 |
|
| 81 |
-
col_order = ['index', 'x', 'y', '
|
| 82 |
'new_temp', 'pp_trees_increase','%total_trees', 'sqm_trees_increase','sqm_total_trees',] # to match gdf trees
|
| 83 |
|
| 84 |
treatment_df = treatment_df[col_order]
|
|
@@ -115,13 +115,13 @@ def process_data_temp_to_trees(goal, simulation_mode, original_df, df, X, Y, T):
|
|
| 115 |
name = 'pp_trees_increase'
|
| 116 |
treatment_df = run_temp_decrease(X, original_df, df, goal, name,simulation_mode)
|
| 117 |
|
| 118 |
-
treatment_df['%total_trees'] = treatment_df['
|
| 119 |
|
| 120 |
#add columns translated to square meters
|
| 121 |
treatment_df['sqm_total_trees'] = (treatment_df['%total_trees']/100)*cell_area
|
| 122 |
treatment_df['sqm_trees_increase'] = (treatment_df['pp_trees_increase']/100)*cell_area
|
| 123 |
|
| 124 |
-
col_order = ['index', 'x', 'y', '
|
| 125 |
'new_temp', 'pp_trees_increase','%total_trees', 'sqm_trees_increase','sqm_total_trees',] # to match gdf trees
|
| 126 |
|
| 127 |
treatment_df = treatment_df[col_order]
|
|
|
|
| 9 |
|
| 10 |
cell_area = 100*100 #in square meters
|
| 11 |
|
| 12 |
+
def make_XYT(df, treatment_col = 'Pct_CoberturaVeg', target_col = 'LST'):
|
| 13 |
|
| 14 |
Y = df[target_col].values
|
| 15 |
|
|
|
|
| 27 |
original_df = original_df.round(2)
|
| 28 |
|
| 29 |
df = original_df[['Elevacion', 'Neighbor_NDBI', 'Proximidad_agua',
|
| 30 |
+
'Neighbor_%CoberturaVeg', 'Pct_CoberturaVeg', 'LST']].copy()
|
| 31 |
df = df.astype(np.float32)
|
| 32 |
|
| 33 |
X, Y, T = make_XYT(df)
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
def prepare_treatment_df(original_df, df):
|
| 39 |
+
treatment_df = original_df[['x','y','Pct_CoberturaVeg']].copy()
|
| 40 |
+
treatment_df.loc[:, 'Pct_Construccion'] = original_df['Pct_Construccion'].values
|
| 41 |
treatment_df.loc[:, 'LST'] = df['LST'].values
|
| 42 |
|
| 43 |
treatment_df = treatment_df.reset_index()
|
|
|
|
| 64 |
|
| 65 |
treatment_df[name] = result["effect"]
|
| 66 |
treatment_df['%total_trees'] = T_sim
|
| 67 |
+
treatment_df['pp_trees_increase'] = treatment_df['%total_trees'] - treatment_df['Pct_CoberturaVeg']
|
| 68 |
|
| 69 |
return treatment_df
|
| 70 |
|
|
|
|
| 78 |
treatment_df['sqm_trees_increase'] = (treatment_df['pp_trees_increase']/100)*cell_area
|
| 79 |
treatment_df['sqm_total_trees'] = (treatment_df['%total_trees']/100)*cell_area
|
| 80 |
|
| 81 |
+
col_order = ['index', 'x', 'y', 'Pct_CoberturaVeg', 'Pct_Construccion', 'LST','temp_decrease',
|
| 82 |
'new_temp', 'pp_trees_increase','%total_trees', 'sqm_trees_increase','sqm_total_trees',] # to match gdf trees
|
| 83 |
|
| 84 |
treatment_df = treatment_df[col_order]
|
|
|
|
| 115 |
name = 'pp_trees_increase'
|
| 116 |
treatment_df = run_temp_decrease(X, original_df, df, goal, name,simulation_mode)
|
| 117 |
|
| 118 |
+
treatment_df['%total_trees'] = treatment_df['Pct_CoberturaVeg'] + treatment_df[name]
|
| 119 |
|
| 120 |
#add columns translated to square meters
|
| 121 |
treatment_df['sqm_total_trees'] = (treatment_df['%total_trees']/100)*cell_area
|
| 122 |
treatment_df['sqm_trees_increase'] = (treatment_df['pp_trees_increase']/100)*cell_area
|
| 123 |
|
| 124 |
+
col_order = ['index', 'x', 'y', 'Pct_CoberturaVeg', 'Pct_Construccion', 'LST','temp_decrease',
|
| 125 |
'new_temp', 'pp_trees_increase','%total_trees', 'sqm_trees_increase','sqm_total_trees',] # to match gdf trees
|
| 126 |
|
| 127 |
treatment_df = treatment_df[col_order]
|
example.csv
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
,x,y,Elevacion,Neighbor_NDBI,Proximidad_agua,Neighbor_%CoberturaVeg,
|
| 2 |
0,769975.0,1617705.0,1462.4218,-0.18309525,234.21106,14.933889,72.46039,26.467785,6.4757442,26.267784,77.46039
|
| 3 |
1,770075.0,1617705.0,1460.5194,-0.17259958,132.40779,54.877888,87.98455,25.810371,2.7551615,25.61037,92.98455
|
| 4 |
2,769875.0,1617605.0,1458.5167,-0.21486245,288.92615,44.12824,97.19963,25.18595,3.9044127,24.985949,102.19963
|
|
|
|
| 1 |
+
,x,y,Elevacion,Neighbor_NDBI,Proximidad_agua,Neighbor_%CoberturaVeg,Pct_CoberturaVeg,LST,Pct_Construccion,simulacion_temp,simulacion_arboles
|
| 2 |
0,769975.0,1617705.0,1462.4218,-0.18309525,234.21106,14.933889,72.46039,26.467785,6.4757442,26.267784,77.46039
|
| 3 |
1,770075.0,1617705.0,1460.5194,-0.17259958,132.40779,54.877888,87.98455,25.810371,2.7551615,25.61037,92.98455
|
| 4 |
2,769875.0,1617605.0,1458.5167,-0.21486245,288.92615,44.12824,97.19963,25.18595,3.9044127,24.985949,102.19963
|
plot_utils.py
CHANGED
|
@@ -38,7 +38,7 @@ def show_two_plots(gdf, name1, name2, vmin, vmax, colorscheme, title1, title2, l
|
|
| 38 |
else:
|
| 39 |
# Split data into three GeoDataFrames
|
| 40 |
# below_100 = gdf[gdf[split] <= 100]
|
| 41 |
-
above_capacity = gdf[gdf[split] > (100-gdf['
|
| 42 |
above_100 = gdf[gdf[split] > 100]
|
| 43 |
above_colors = {"capacity":"chocolate", "100":"firebrick"}
|
| 44 |
|
|
|
|
| 38 |
else:
|
| 39 |
# Split data into three GeoDataFrames
|
| 40 |
# below_100 = gdf[gdf[split] <= 100]
|
| 41 |
+
above_capacity = gdf[gdf[split] > (100-gdf['Pct_Construccion'])]
|
| 42 |
above_100 = gdf[gdf[split] > 100]
|
| 43 |
above_colors = {"capacity":"chocolate", "100":"firebrick"}
|
| 44 |
|