From 24b0c566152b604c2e4d18325d8ef5ed451848c0 Mon Sep 17 00:00:00 2001
From: nck00 <50334352+nck00@users.noreply.github.com>
Date: Thu, 16 Mar 2023 20:26:06 +0100
Subject: [PATCH 1/2] Update requirements.txt
Updated for Py311 (Scipy package was not available)
---
requirements.txt | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index 9f182a9..0d16285 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,30 +1,31 @@
-branca==0.5.0
+branca==0.6.0
certifi==2022.12.7
-charset-normalizer==2.1.0
+charset-normalizer==3.1.0
+contourpy==1.0.7
cycler==0.11.0
et-xmlfile==1.1.0
-folium==0.12.1.post1
-fonttools==4.33.3
-idna==3.3
+folium==0.14.0
+fonttools==4.39.2
+idna==3.4
Jinja2==3.1.2
joblib==1.2.0
-kiwisolver==1.4.3
-lxml==4.9.1
-MarkupSafe==2.1.1
-matplotlib==3.5.2
-numpy==1.23.0
-openpyxl==3.0.10
-packaging==21.3
-Pillow==9.3.0
+kiwisolver==1.4.4
+lxml==4.9.2
+MarkupSafe==2.1.2
+matplotlib==3.7.1
+numpy==1.24.2
+openpyxl==3.1.2
+packaging==23.0
+Pillow==9.4.0
pyparsing==3.0.9
-PyQt5==5.15.7
+PyQt5==5.15.9
PyQt5-Qt5==5.15.2
-PyQt5-sip==12.11.0
+PyQt5-sip==12.11.1
python-dateutil==2.8.2
python-docx==0.8.11
-requests==2.28.1
-scikit-learn==1.1.1
-scipy==1.8.1
+requests==2.28.2
+scikit-learn==1.2.2
+scipy==1.10.1
six==1.16.0
threadpoolctl==3.1.0
-urllib3==1.26.9
+urllib3==1.26.15
\ No newline at end of file
From 7843205c8484cb059e725c38ce6d7189330dce88 Mon Sep 17 00:00:00 2001
From: nck00 <50334352+nck00@users.noreply.github.com>
Date: Sat, 3 Jun 2023 22:46:17 +0200
Subject: [PATCH 2/2] Euclidean Distance - Minimum Value
Added an option to set a minimum distance value to which all values below are set to, while ignoring no Data values.
---
.../uis/Geoprocessing_ui/EuclideanDistance.ui | 34 +++++++++++++------
.../Geoprocessing_ui/EuclideanDistance_ui.py | 31 +++++++++++------
.../euclideanDistance_main.py | 14 ++++++--
3 files changed, 56 insertions(+), 23 deletions(-)
diff --git a/core/uis/Geoprocessing_ui/EuclideanDistance.ui b/core/uis/Geoprocessing_ui/EuclideanDistance.ui
index ed3f6c5..2e8b1f9 100644
--- a/core/uis/Geoprocessing_ui/EuclideanDistance.ui
+++ b/core/uis/Geoprocessing_ui/EuclideanDistance.ui
@@ -6,8 +6,8 @@
0
0
- 540
- 400
+ 580
+ 450
@@ -95,9 +95,6 @@
- -
-
-
-
@@ -119,6 +116,9 @@
+ -
+
+
@@ -139,7 +139,7 @@
-
-
-
+
-
Fixed buffer value
@@ -147,26 +147,40 @@
-
+
+
+ Minimum distance
+
+
+
+ -
Maximum distance
- -
+
-
The maximum distance to be generated. The nodata value will be used for pixels beyond this distance.
- -
+
-
Specify a value to be applied to all pixels that are within the -maxdist of target pixels (including the target pixels) instead of a distance value
+ -
+
+
+
+
+
+
@@ -181,8 +195,8 @@
0
0
- 540
- 18
+ 580
+ 21
diff --git a/core/uis/Geoprocessing_ui/EuclideanDistance_ui.py b/core/uis/Geoprocessing_ui/EuclideanDistance_ui.py
index aeb00e6..beed44a 100644
--- a/core/uis/Geoprocessing_ui/EuclideanDistance_ui.py
+++ b/core/uis/Geoprocessing_ui/EuclideanDistance_ui.py
@@ -2,9 +2,10 @@
# Form implementation generated from reading ui file '.\EuclideanDistance.ui'
#
-# Created by: PyQt5 UI code generator 5.14.2
+# Created by: PyQt5 UI code generator 5.15.9
#
-# WARNING! All changes made in this file will be lost!
+# WARNING: Any manual changes made to this file will be lost when pyuic5 is
+# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
@@ -13,7 +14,7 @@
class Ui_EuclideanDistanceForm(object):
def setupUi(self, EuclideanDistanceForm):
EuclideanDistanceForm.setObjectName("EuclideanDistanceForm")
- EuclideanDistanceForm.resize(540, 400)
+ EuclideanDistanceForm.resize(580, 450)
self.centralwidget = QtWidgets.QWidget(EuclideanDistanceForm)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
@@ -56,9 +57,6 @@ def setupUi(self, EuclideanDistanceForm):
self.maskRasterToolButton.setEnabled(False)
self.maskRasterToolButton.setObjectName("maskRasterToolButton")
self.inputDataGroupBoxGridLayout.addWidget(self.maskRasterToolButton, 4, 3, 1, 1)
- self.inputFeatureLineEdit = QtWidgets.QLineEdit(self.inputDataGroupBox)
- self.inputFeatureLineEdit.setObjectName("inputFeatureLineEdit")
- self.inputDataGroupBoxGridLayout.addWidget(self.inputFeatureLineEdit, 1, 0, 1, 2)
self.inputFeatureDatasetLabel = QtWidgets.QLabel(self.inputDataGroupBox)
self.inputFeatureDatasetLabel.setObjectName("inputFeatureDatasetLabel")
self.inputDataGroupBoxGridLayout.addWidget(self.inputFeatureDatasetLabel, 0, 0, 1, 1)
@@ -69,6 +67,9 @@ def setupUi(self, EuclideanDistanceForm):
self.maskRasterLineEdit.setEnabled(False)
self.maskRasterLineEdit.setObjectName("maskRasterLineEdit")
self.inputDataGroupBoxGridLayout.addWidget(self.maskRasterLineEdit, 4, 0, 1, 3)
+ self.inputFeatureLineEdit = QtWidgets.QLineEdit(self.inputDataGroupBox)
+ self.inputFeatureLineEdit.setObjectName("inputFeatureLineEdit")
+ self.inputDataGroupBoxGridLayout.addWidget(self.inputFeatureLineEdit, 1, 0, 1, 3)
self.horizontalLayout.addLayout(self.inputDataGroupBoxGridLayout)
self.mainGridLayout.addWidget(self.inputDataGroupBox, 0, 0, 1, 2)
self.applyPushButton = QtWidgets.QPushButton(self.centralwidget)
@@ -82,22 +83,29 @@ def setupUi(self, EuclideanDistanceForm):
self.optionalSettingsGroupBoxGridLayout.setObjectName("optionalSettingsGroupBoxGridLayout")
self.fixedBufferValueLabel = QtWidgets.QLabel(self.optionalSettingsGroupBox)
self.fixedBufferValueLabel.setObjectName("fixedBufferValueLabel")
- self.optionalSettingsGroupBoxGridLayout.addWidget(self.fixedBufferValueLabel, 2, 0, 1, 1)
+ self.optionalSettingsGroupBoxGridLayout.addWidget(self.fixedBufferValueLabel, 4, 0, 1, 1)
+ self.minimumDistanceLabel = QtWidgets.QLabel(self.optionalSettingsGroupBox)
+ self.minimumDistanceLabel.setObjectName("minimumDistanceLabel")
+ self.optionalSettingsGroupBoxGridLayout.addWidget(self.minimumDistanceLabel, 0, 0, 1, 1)
self.maximumDistanceLabel = QtWidgets.QLabel(self.optionalSettingsGroupBox)
self.maximumDistanceLabel.setObjectName("maximumDistanceLabel")
- self.optionalSettingsGroupBoxGridLayout.addWidget(self.maximumDistanceLabel, 0, 0, 1, 1)
+ self.optionalSettingsGroupBoxGridLayout.addWidget(self.maximumDistanceLabel, 2, 0, 1, 1)
self.maximumDistanceLineEdit = QtWidgets.QLineEdit(self.optionalSettingsGroupBox)
self.maximumDistanceLineEdit.setObjectName("maximumDistanceLineEdit")
- self.optionalSettingsGroupBoxGridLayout.addWidget(self.maximumDistanceLineEdit, 1, 0, 1, 1)
+ self.optionalSettingsGroupBoxGridLayout.addWidget(self.maximumDistanceLineEdit, 3, 0, 1, 1)
self.fixedBufferValueLineEdit = QtWidgets.QLineEdit(self.optionalSettingsGroupBox)
self.fixedBufferValueLineEdit.setObjectName("fixedBufferValueLineEdit")
- self.optionalSettingsGroupBoxGridLayout.addWidget(self.fixedBufferValueLineEdit, 3, 0, 1, 1)
+ self.optionalSettingsGroupBoxGridLayout.addWidget(self.fixedBufferValueLineEdit, 5, 0, 1, 1)
+ self.minimumDistanceLineEdit = QtWidgets.QLineEdit(self.optionalSettingsGroupBox)
+ self.minimumDistanceLineEdit.setText("")
+ self.minimumDistanceLineEdit.setObjectName("minimumDistanceLineEdit")
+ self.optionalSettingsGroupBoxGridLayout.addWidget(self.minimumDistanceLineEdit, 1, 0, 1, 1)
self.verticalLayout_2.addLayout(self.optionalSettingsGroupBoxGridLayout)
self.mainGridLayout.addWidget(self.optionalSettingsGroupBox, 1, 0, 1, 2)
self.verticalLayout.addLayout(self.mainGridLayout)
EuclideanDistanceForm.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(EuclideanDistanceForm)
- self.menubar.setGeometry(QtCore.QRect(0, 0, 540, 18))
+ self.menubar.setGeometry(QtCore.QRect(0, 0, 580, 21))
self.menubar.setObjectName("menubar")
EuclideanDistanceForm.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(EuclideanDistanceForm)
@@ -131,6 +139,7 @@ def retranslateUi(self, EuclideanDistanceForm):
self.applyPushButton.setText(_translate("EuclideanDistanceForm", "Apply"))
self.optionalSettingsGroupBox.setTitle(_translate("EuclideanDistanceForm", "Optional settings"))
self.fixedBufferValueLabel.setText(_translate("EuclideanDistanceForm", "Fixed buffer value"))
+ self.minimumDistanceLabel.setText(_translate("EuclideanDistanceForm", "Minimum distance"))
self.maximumDistanceLabel.setText(_translate("EuclideanDistanceForm", "Maximum distance"))
self.maximumDistanceLineEdit.setToolTip(_translate("EuclideanDistanceForm", "The maximum distance to be generated. The nodata value will be used for pixels beyond this distance. "))
self.fixedBufferValueLineEdit.setToolTip(_translate("EuclideanDistanceForm", "Specify a value to be applied to all pixels that are within the -maxdist of target pixels (including the target pixels) instead of a distance value"))
diff --git a/core/widgets/EuclideanDistance/euclideanDistance_main.py b/core/widgets/EuclideanDistance/euclideanDistance_main.py
index f1273b4..26d24a2 100644
--- a/core/widgets/EuclideanDistance/euclideanDistance_main.py
+++ b/core/widgets/EuclideanDistance/euclideanDistance_main.py
@@ -96,13 +96,18 @@ def on_applyPushButton_clicked(self):
self.featurePath = self.ui.inputFeatureLineEdit.text()
self.outRasterPath = self.ui.outRasterLineEdit.text()
self.maskRasterPath = self.ui.maskRasterLineEdit.text()
+ if self.ui.minimumDistanceLineEdit.text():
+ self.minDistance = float(self.ui.minimumDistanceLineEdit.text())
+ else:
+ self.minDistance = None
args = (
self.featurePath,
self.outRasterPath,
self.maskRasterPath,
self.projectLocation,
options,
- self.ui.ignoreOutsideCheckBox.isChecked())
+ self.ui.ignoreOutsideCheckBox.isChecked(),
+ self.minDistance)
self.calcEuclideanDistance = EuclideanDistanceAnalysis(args)
self.thread = QThread()
self.calcEuclideanDistance.moveToThread(self.thread)
@@ -128,7 +133,7 @@ class EuclideanDistanceAnalysis(QObject):
def __init__(self, args):
QObject.__init__(self)
- self.featurePath, self.outRasterPath, self.maskRasterPath, self.projectLocation, self.options, self.ignoreOutsideMask = args
+ self.featurePath, self.outRasterPath, self.maskRasterPath, self.projectLocation, self.options, self.ignoreOutsideMask, self.minDistance = args
def calcDistance(self):
"""
@@ -177,6 +182,11 @@ def calcDistance(self):
euclideanBand = euclidean.GetRasterBand(1)
euclideanBand.SetNoDataValue(noDataValue)
gdal.ComputeProximity(featRasterBand, euclideanBand, self.options, callback=None)
+ if self.minDistance != None:
+ euclideanArray = euclideanBand.ReadAsArray()
+ euclideanArray[(euclideanArray < self.minDistance) & (euclideanArray != noDataValue)] = self.minDistance
+ euclideanBand.WriteArray(euclideanArray)
+ self.updateLoggerSignal.emit(self.tr("Distance values under {} set to {}.").format(self.minDistance, self.minDistance))
euclideanBand.ComputeStatistics(False)
featRaster = None
euclidean = None