Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates on WTP outputs #76

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions gender_indicator_tool/gender_indicator_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@
from PyQt5.QtWidgets import QFileDialog, QApplication
from qgis.core import *

# package installs


# Auxiliary libraries
import os
import sys
import geopandas as gpd
import pandas as pd
from rasterio.crs import CRS
import rasterio
from rasterio.crs import CRS
import numpy as np
import math
import shutil
Expand All @@ -43,6 +46,7 @@
import ast
from rasterio.mask import mask
from rasterio.features import geometry_mask
import csv

# Prepare processing framework
# sys.path.append(r'C:\Program Files\QGIS 3.32.0\apps\qgis\python\plugins') # Folder where Processing is located
Expand Down Expand Up @@ -689,7 +693,7 @@ def Rasterize(self, factor_no):
self.dlg.DIG_status.repaint()

elif factor_no == 6:
polygonlayer = self.dlg.FCV_Input_Field.filePath()
csvFile = self.dlg.FCV_Input_Field.filePath()
rasField = self.dlg.FCV_rasField_CB.currentText()
self.dlg.FCV_status.setText("Variables Set")
self.dlg.FCV_status.repaint()
Expand Down Expand Up @@ -1221,6 +1225,13 @@ def Rasterize(self, factor_no):

elif factor_no == 6:
shp_utm[rasField] = (shp_utm[rasField] - Rmin) / (Rmax - Rmin) * m_max

# csv conversion to shapefile

with open(csvFile, 'r') as csv_file:
reader = csv.DictReader(csv_file)
field_names = reader.fieldnames

polygonUTM = QgsVectorLayer(shp_utm.to_json(), "polygonUTM", "ogr")

clipPolygonUTM = processing.run(
Expand Down Expand Up @@ -1526,6 +1537,8 @@ def ServiceArea(self, factor_no):
facility_data = 0
for FaciltyPointlayer in FaciltyPointlayerList:
os.chdir(workingDir)
base_name = os.path.basename(FaciltyPointlayer)
shapefile_name, _ = os.path.splitext(base_name)
gdf = gpd.read_file(FaciltyPointlayer)

subset_size = 5
Expand Down Expand Up @@ -1764,7 +1777,7 @@ def ServiceArea(self, factor_no):
else:
pass

rasOutput = f"{self.dlg.WTP_FacilityOutput_Field.text()[:-4]}{self.dlg.WTP_mode_CB.currentText()}_{facility_data}.tif"
rasOutput = f"{self.dlg.WTP_FacilityOutput_Field.text()[:-4]}{self.dlg.WTP_mode_CB.currentText()}_{shapefile_name}.tif"

rasterize = processing.run(
"gdal:rasterize",
Expand Down
8 changes: 4 additions & 4 deletions gender_indicator_tool/gender_indicator_tool_dialog_base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ p, li { white-space: pre-wrap; }
<item row="14" column="0" colspan="2">
<widget class="QgsFilterLineEdit" name="WTP_Ranges_Field">
<property name="text">
<string>400, 800, 1200, 1600, 2000</string>
<string>400, 800, 1200, 1500, 2000</string>
</property>
<property name="qgisRelation" stdset="0">
<string notr="true"/>
Expand Down Expand Up @@ -1432,7 +1432,7 @@ p, li { white-space: pre-wrap; }
<item row="7" column="0" colspan="2">
<widget class="QgsFilterLineEdit" name="HEA_Ranges_Field">
<property name="text">
<string>1000, 2000, 3000, 4000, 5000</string>
<string>2000, 4000, 6000, 8000, 10000</string>
</property>
<property name="qgisRelation" stdset="0">
<string notr="true"/>
Expand Down Expand Up @@ -2662,7 +2662,7 @@ p, li { white-space: pre-wrap; }
</size>
</property>
<property name="text">
<string>Point Input Layer</string>
<string>Input CSV File</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -2701,7 +2701,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:20pt; font-weight:600; color:#535353;&quot;&gt;Fragility, conflict, and violence&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:20pt; font-weight:600; color:#535353;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;justify&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;   &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a name=&quot;_Hlk146891458&quot;&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600;&quot;&gt;I&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600;&quot;&gt;nput&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;: A Point layer (.shp) &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a name=&quot;_Hlk146891458&quot;&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600;&quot;&gt;I&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600;&quot;&gt;nput&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;: ACLED data (,csv}&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:600;&quot;&gt;Output&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;: A raster file containing values ranging from 0 to 5 is saved to the output directory.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
Expand Down