mirror of https://gitlab.com/pamhyr/pamhyr2
debug + disable rasterio
parent
5f6c823301
commit
7ef3184699
|
|
@ -19,7 +19,7 @@
|
||||||
import os
|
import os
|
||||||
import csv
|
import csv
|
||||||
import logging
|
import logging
|
||||||
import rasterio
|
# import rasterio
|
||||||
|
|
||||||
from numpy import sqrt
|
from numpy import sqrt
|
||||||
|
|
||||||
|
|
@ -338,6 +338,8 @@ class ResultsWindow(PamhyrWindow):
|
||||||
# "action_export": self.export_current,
|
# "action_export": self.export_current,
|
||||||
"action_Geo_tiff": self.import_geotiff
|
"action_Geo_tiff": self.import_geotiff
|
||||||
}
|
}
|
||||||
|
self.find(QAction, "action_Geo_tiff").setEnabled(False)
|
||||||
|
self.find(QAction, "action_Geo_tiff").setVisible(False)
|
||||||
|
|
||||||
if len(self._results) > 1:
|
if len(self._results) > 1:
|
||||||
self.find(QAction, "action_reload").setEnabled(False)
|
self.find(QAction, "action_reload").setEnabled(False)
|
||||||
|
|
@ -1166,47 +1168,48 @@ class ResultsWindow(PamhyrWindow):
|
||||||
self.update_table_selection_profile(profile_id)
|
self.update_table_selection_profile(profile_id)
|
||||||
|
|
||||||
def import_geotiff(self):
|
def import_geotiff(self):
|
||||||
options = QFileDialog.Options()
|
# options = QFileDialog.Options()
|
||||||
settings = QSettings(QSettings.IniFormat,
|
# settings = QSettings(QSettings.IniFormat,
|
||||||
QSettings.UserScope, 'MyOrg', )
|
# QSettings.UserScope, 'MyOrg', )
|
||||||
options |= QFileDialog.DontUseNativeDialog
|
# options |= QFileDialog.DontUseNativeDialog
|
||||||
|
#
|
||||||
file_types = [
|
# file_types = [
|
||||||
self._trad["file_geotiff"],
|
# self._trad["file_geotiff"],
|
||||||
self._trad["file_all"],
|
# self._trad["file_all"],
|
||||||
]
|
# ]
|
||||||
|
#
|
||||||
filename, _ = QFileDialog.getOpenFileName(
|
# filename, _ = QFileDialog.getOpenFileName(
|
||||||
self,
|
# self,
|
||||||
self._trad["open_file"],
|
# self._trad["open_file"],
|
||||||
"",
|
# "",
|
||||||
";; ".join(file_types),
|
# ";; ".join(file_types),
|
||||||
options=options
|
# options=options
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
if filename != "":
|
# if filename != "":
|
||||||
with rasterio.open(filename) as data:
|
# with rasterio.open(filename) as data:
|
||||||
img = data.read()
|
# img = data.read()
|
||||||
b = data.bounds[:]
|
# b = data.bounds[:]
|
||||||
# b[0] left
|
# # b[0] left
|
||||||
# b[1] bottom
|
# # b[1] bottom
|
||||||
# b[2] right
|
# # b[2] right
|
||||||
# b[3] top
|
# # b[3] top
|
||||||
xlim = self.canvas.axes.get_xlim()
|
# xlim = self.canvas.axes.get_xlim()
|
||||||
ylim = self.canvas.axes.get_ylim()
|
# ylim = self.canvas.axes.get_ylim()
|
||||||
if b[2] > b[0] and b[1] < b[3]:
|
# if b[2] > b[0] and b[1] < b[3]:
|
||||||
self.canvas.axes.imshow(img.transpose((1, 2, 0)),
|
# self.canvas.axes.imshow(img.transpose((1, 2, 0)),
|
||||||
extent=[b[0], b[2], b[1], b[3]])
|
# extent=[b[0], b[2], b[1], b[3]])
|
||||||
else:
|
# else:
|
||||||
dlg = CoordinatesDialog(
|
# dlg = CoordinatesDialog(
|
||||||
xlim,
|
# xlim,
|
||||||
ylim,
|
# ylim,
|
||||||
trad=self._trad,
|
# trad=self._trad,
|
||||||
parent=self
|
# parent=self
|
||||||
)
|
# )
|
||||||
if dlg.exec():
|
# if dlg.exec():
|
||||||
self.canvas.axes.imshow(img.transpose((1, 2, 0)),
|
# self.canvas.axes.imshow(img.transpose((1, 2, 0)),
|
||||||
extent=dlg.values)
|
# extent=dlg.values)
|
||||||
self.plot_xy.idle()
|
# self.plot_xy.idle()
|
||||||
self.canvas.axes.set_xlim(xlim)
|
# self.canvas.axes.set_xlim(xlim)
|
||||||
self.canvas.axes.set_ylim(ylim)
|
# self.canvas.axes.set_ylim(ylim)
|
||||||
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue