mirror of https://gitlab.com/pamhyr/pamhyr2
test background img import
parent
3e8132646d
commit
5ba38d5cd6
|
|
@ -12,3 +12,5 @@ shapely>=2.0.1
|
||||||
lxml>=4.9.3
|
lxml>=4.9.3
|
||||||
platformdirs>=4.2.0
|
platformdirs>=4.2.0
|
||||||
pyshp>=2.3.1
|
pyshp>=2.3.1
|
||||||
|
rasterio==1.3.11
|
||||||
|
#fortranformat==2.0.3
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
import os
|
import os
|
||||||
import csv
|
import csv
|
||||||
import logging
|
import logging
|
||||||
|
import rasterio
|
||||||
|
|
||||||
from numpy import sqrt
|
from numpy import sqrt
|
||||||
|
|
||||||
|
|
@ -35,6 +36,7 @@ from PyQt5.QtCore import (
|
||||||
Qt, QVariant, QAbstractTableModel,
|
Qt, QVariant, QAbstractTableModel,
|
||||||
QCoreApplication, QModelIndex, pyqtSlot,
|
QCoreApplication, QModelIndex, pyqtSlot,
|
||||||
QItemSelectionModel, QTimer,
|
QItemSelectionModel, QTimer,
|
||||||
|
QSettings
|
||||||
)
|
)
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
|
|
@ -334,6 +336,7 @@ class ResultsWindow(PamhyrWindow):
|
||||||
"action_add": self._add_custom_plot,
|
"action_add": self._add_custom_plot,
|
||||||
"action_export": self._export,
|
"action_export": self._export,
|
||||||
# "action_export": self.export_current,
|
# "action_export": self.export_current,
|
||||||
|
"action_Geo_tiff": self.import_geotiff
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(self._results) > 1:
|
if len(self._results) > 1:
|
||||||
|
|
@ -1162,3 +1165,39 @@ class ResultsWindow(PamhyrWindow):
|
||||||
profile_id = self._get_current_profile()
|
profile_id = self._get_current_profile()
|
||||||
self.update_table_selection_profile(profile_id)
|
self.update_table_selection_profile(profile_id)
|
||||||
|
|
||||||
|
def import_geotiff(self):
|
||||||
|
options = QFileDialog.Options()
|
||||||
|
settings = QSettings(QSettings.IniFormat,
|
||||||
|
QSettings.UserScope, 'MyOrg', )
|
||||||
|
options |= QFileDialog.DontUseNativeDialog
|
||||||
|
|
||||||
|
file_types = [
|
||||||
|
self._trad["file_geotiff"],
|
||||||
|
self._trad["file_all"],
|
||||||
|
]
|
||||||
|
|
||||||
|
filename, _ = QFileDialog.getOpenFileName(
|
||||||
|
self,
|
||||||
|
self._trad["open_file"],
|
||||||
|
"",
|
||||||
|
";; ".join(file_types),
|
||||||
|
options=options
|
||||||
|
)
|
||||||
|
|
||||||
|
if filename != "":
|
||||||
|
with rasterio.open(filename) as data:
|
||||||
|
img = data.read()
|
||||||
|
b = data.bounds[:]
|
||||||
|
# b[0] left
|
||||||
|
# b[1] bottom
|
||||||
|
# b[2] right
|
||||||
|
# b[3] top
|
||||||
|
if b[2] < b[0] and b[1] < b[3]:
|
||||||
|
self.canvas.axes.imshow(img.transpose((1, 2, 0)), extent=[b[0], b[2], b[1], b[3]])
|
||||||
|
else:
|
||||||
|
x = self.canvas.axes.get_xlim()
|
||||||
|
y = self.canvas.axes.get_ylim()
|
||||||
|
self.canvas.axes.imshow(img.transpose((1, 2, 0)), extent=[x[0], x[1], y[0], y[1]])
|
||||||
|
self.plot_xy.idle()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,9 @@ class ResultsTranslate(MainTranslate):
|
||||||
"Results",
|
"Results",
|
||||||
"Max water elevation"
|
"Max water elevation"
|
||||||
)
|
)
|
||||||
|
self._dict["file_all"] = _translate("GeoTIFF", "All files (*)")
|
||||||
|
self._dict["file_geotiff"] = _translate(
|
||||||
|
"GeoTIFF", "GeoTIFF file (*.tiff *.tif)")
|
||||||
|
|
||||||
self._sub_dict["table_headers_reach"] = {
|
self._sub_dict["table_headers_reach"] = {
|
||||||
"name": _translate("Results", "Reach name"),
|
"name": _translate("Results", "Reach name"),
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,7 @@
|
||||||
<addaction name="action_add"/>
|
<addaction name="action_add"/>
|
||||||
<addaction name="action_export"/>
|
<addaction name="action_export"/>
|
||||||
<addaction name="action_reload"/>
|
<addaction name="action_reload"/>
|
||||||
|
<addaction name="action_Geo_tiff"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="action_add">
|
<action name="action_add">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
|
|
@ -275,6 +276,14 @@
|
||||||
<string>Ctrl+E</string>
|
<string>Ctrl+E</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="action_Geo_tiff">
|
||||||
|
<property name="text">
|
||||||
|
<string>Geo tiff</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Import Geo tiff image</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue