From 95512d05318951152887578674329e1d34171e86 Mon Sep 17 00:00:00 2001 From: Gabriel Couture Date: Fri, 9 Apr 2021 14:51:36 -0400 Subject: [PATCH] Adding a final score column in the aggregate tool --- othello/ui/aggregate.py | 8 ++++++++ setup.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/othello/ui/aggregate.py b/othello/ui/aggregate.py index db0b040..158c377 100644 --- a/othello/ui/aggregate.py +++ b/othello/ui/aggregate.py @@ -109,6 +109,8 @@ def assert_weights_are_normalized(self): raise errors.SumOfWeightNotEqualsToOneError def add_weighted_columns(self, df: geopandas.GeoDataFrame) -> geopandas.GeoDataFrame: + weighted_columns = [] + for row_index in range(self.table.rowCount()): filepath = self.table.item(row_index, 0).text() layer = self.table.item(row_index, 1).text() @@ -118,6 +120,12 @@ def add_weighted_columns(self, df: geopandas.GeoDataFrame) -> geopandas.GeoDataF criterion_geoseries = gis.io.read(filepath, layer=layer)[criterion] df[criterion + '_np'] = criterion_geoseries df[criterion + '_p'] = weight * criterion_geoseries + weighted_columns.append(criterion + '_p') + + # Final score in a new series + df['FinalScore'] = [0 for i in range(len(df))] + for column in weighted_columns: + df['FinalScore'] += df[column] return df diff --git a/setup.py b/setup.py index c962199..d3e197f 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ version='0.1', description='Tools that allow you to read and manipulate M-MACBETH files and transform GIS data accordingly.', options={'build_exe': build_exe_options}, - executables=[Executable('othello/othello.py', base=base)], + executables=[Executable('othello/app.py', base=base)], cmdclass={ 'clean_build': CleanBuild, }