GeoTIFF: Fix coordinates.

scenario-dev-pa
Pierre-Antoine 2025-11-19 11:46:22 +01:00
parent f8a41fce08
commit 2c49e991b4
4 changed files with 34 additions and 10 deletions

View File

@ -189,7 +189,12 @@ class EditGeoTIFFWindow(PamhyrWindow):
def update_values_from_spinbox(self, key):
self._values[key] = self.get_double_spin_box(f"doubleSpinBox_{key}")
self._plot_img.set_extent(list(self._values.values()))
left = self._values["left"]
right = self._values["right"]
bottom = self._values["bottom"]
top = self._values["top"]
self._plot_img.set_extent((left, right, bottom, top))
self.plot.idle()
def draw_geotiff(self, memfile=None):
@ -205,11 +210,11 @@ class EditGeoTIFFWindow(PamhyrWindow):
b = data.bounds[:] # left, bottom, right, top
if b[2] > b[0] and b[1] < b[3]:
coord = [b[0], b[2], b[1], b[3]]
coord = [b[1], b[3], b[0], b[2]]
else:
xlim = self.canvas.axes.get_xlim()
ylim = self.canvas.axes.get_ylim()
coord = xlim + ylim
coord = ylim + xlim
self._set_values_from_bounds(coord)
self._set_default_values_from_bounds(coord)
@ -220,9 +225,14 @@ class EditGeoTIFFWindow(PamhyrWindow):
if self._plot_img is not None:
self._plot_img.remove()
left = self._values["left"]
right = self._values["right"]
bottom = self._values["bottom"]
top = self._values["top"]
self._plot_img = self.canvas.axes.imshow(
img.transpose((1, 2, 0)),
extent=list(self._values.values())
extent=(left, right, bottom, top)
)
self.plot.idle()

View File

@ -140,12 +140,16 @@ class GeoTIFFListWindow(PamhyrWindow):
return
for row in rows:
geotiff = self._study.river.geotiff.files[row]
files = self._study.river.geotiff.files
if len(files) <= row:
continue
geotiff = files[row]
coord = geotiff.coordinates
xy = (coord["bottom"], coord["left"])
width = abs(coord["top"] - coord["bottom"])
height = abs(coord["right"] - coord["left"])
xy = (coord["left"], coord["bottom"])
width = abs(coord["right"] - coord["left"])
height = abs(coord["top"] - coord["bottom"])
rect = Rectangle(
xy, width, height,

View File

@ -157,9 +157,14 @@ class PlotXY(PamhyrPlot):
img = gt.read()
coords = geotiff.coordinates
left = coords["left"]
right = coords["right"]
bottom = coords["bottom"]
top = coords["top"]
self._plot_img[geotiff] = self.canvas.axes.imshow(
img.transpose((1, 2, 0)),
extent=list(coords.values())
extent=(left, right, bottom, top)
)
if not geotiff.is_enabled():

View File

@ -344,9 +344,14 @@ class PlotXY(PamhyrPlot):
img = gt.read()
coords = geotiff.coordinates
left = coords["left"]
right = coords["right"]
bottom = coords["bottom"]
top = coords["top"]
self._plot_img[geotiff] = self.canvas.axes.imshow(
img.transpose((1, 2, 0)),
extent=list(coords.values())
extent=(left, right, bottom, top)
)
if not geotiff.is_enabled():