Skip to content

Commit

Permalink
Adding a final score column in the aggregate tool
Browse files Browse the repository at this point in the history
  • Loading branch information
gacou54 committed Apr 9, 2021
1 parent d69fa8f commit 95512d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions othello/ui/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 95512d0

Please sign in to comment.