mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
test background img import
This commit is contained in:
1 parent
3e8132646d
commit
5ba38d5cd6
4 files changed
+53
No files matched your search
@@ -19,6 +19,7 @@
|
||||
import os
|
||||
import csv
|
||||
import logging
|
||||
import rasterio
|
||||
|
||||
from numpy import sqrt
|
||||
|
||||
@@ -35,6 +36,7 @@ from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QItemSelectionModel, QTimer,
|
||||
QSettings
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
@@ -334,6 +336,7 @@ class ResultsWindow(PamhyrWindow):
|
||||
"action_add": self._add_custom_plot,
|
||||
"action_export": self._export,
|
||||
# "action_export": self.export_current,
|
||||
"action_Geo_tiff": self.import_geotiff
|
||||
}
|
||||
|
||||
if len(self._results) > 1:
|
||||
@@ -1162,3 +1165,39 @@ class ResultsWindow(PamhyrWindow):
|
||||
profile_id = self._get_current_profile()
|
||||
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()
|
||||
|
||||
|
||||
Reference in new issue
Block a user