mirror of https://gitlab.com/pamhyr/pamhyr2
GeoTIFF: Fix coordinates.
parent
f8a41fce08
commit
2c49e991b4
|
|
@ -189,7 +189,12 @@ class EditGeoTIFFWindow(PamhyrWindow):
|
||||||
def update_values_from_spinbox(self, key):
|
def update_values_from_spinbox(self, key):
|
||||||
self._values[key] = self.get_double_spin_box(f"doubleSpinBox_{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()
|
self.plot.idle()
|
||||||
|
|
||||||
def draw_geotiff(self, memfile=None):
|
def draw_geotiff(self, memfile=None):
|
||||||
|
|
@ -205,11 +210,11 @@ class EditGeoTIFFWindow(PamhyrWindow):
|
||||||
b = data.bounds[:] # left, bottom, right, top
|
b = data.bounds[:] # left, bottom, right, top
|
||||||
|
|
||||||
if b[2] > b[0] and b[1] < b[3]:
|
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:
|
else:
|
||||||
xlim = self.canvas.axes.get_xlim()
|
xlim = self.canvas.axes.get_xlim()
|
||||||
ylim = self.canvas.axes.get_ylim()
|
ylim = self.canvas.axes.get_ylim()
|
||||||
coord = xlim + ylim
|
coord = ylim + xlim
|
||||||
|
|
||||||
self._set_values_from_bounds(coord)
|
self._set_values_from_bounds(coord)
|
||||||
self._set_default_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:
|
if self._plot_img is not None:
|
||||||
self._plot_img.remove()
|
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(
|
self._plot_img = self.canvas.axes.imshow(
|
||||||
img.transpose((1, 2, 0)),
|
img.transpose((1, 2, 0)),
|
||||||
extent=list(self._values.values())
|
extent=(left, right, bottom, top)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.plot.idle()
|
self.plot.idle()
|
||||||
|
|
|
||||||
|
|
@ -140,12 +140,16 @@ class GeoTIFFListWindow(PamhyrWindow):
|
||||||
return
|
return
|
||||||
|
|
||||||
for row in rows:
|
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
|
coord = geotiff.coordinates
|
||||||
|
|
||||||
xy = (coord["bottom"], coord["left"])
|
xy = (coord["left"], coord["bottom"])
|
||||||
width = abs(coord["top"] - coord["bottom"])
|
width = abs(coord["right"] - coord["left"])
|
||||||
height = abs(coord["right"] - coord["left"])
|
height = abs(coord["top"] - coord["bottom"])
|
||||||
|
|
||||||
rect = Rectangle(
|
rect = Rectangle(
|
||||||
xy, width, height,
|
xy, width, height,
|
||||||
|
|
|
||||||
|
|
@ -157,9 +157,14 @@ class PlotXY(PamhyrPlot):
|
||||||
img = gt.read()
|
img = gt.read()
|
||||||
coords = geotiff.coordinates
|
coords = geotiff.coordinates
|
||||||
|
|
||||||
|
left = coords["left"]
|
||||||
|
right = coords["right"]
|
||||||
|
bottom = coords["bottom"]
|
||||||
|
top = coords["top"]
|
||||||
|
|
||||||
self._plot_img[geotiff] = self.canvas.axes.imshow(
|
self._plot_img[geotiff] = self.canvas.axes.imshow(
|
||||||
img.transpose((1, 2, 0)),
|
img.transpose((1, 2, 0)),
|
||||||
extent=list(coords.values())
|
extent=(left, right, bottom, top)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not geotiff.is_enabled():
|
if not geotiff.is_enabled():
|
||||||
|
|
|
||||||
|
|
@ -344,9 +344,14 @@ class PlotXY(PamhyrPlot):
|
||||||
img = gt.read()
|
img = gt.read()
|
||||||
coords = geotiff.coordinates
|
coords = geotiff.coordinates
|
||||||
|
|
||||||
|
left = coords["left"]
|
||||||
|
right = coords["right"]
|
||||||
|
bottom = coords["bottom"]
|
||||||
|
top = coords["top"]
|
||||||
|
|
||||||
self._plot_img[geotiff] = self.canvas.axes.imshow(
|
self._plot_img[geotiff] = self.canvas.axes.imshow(
|
||||||
img.transpose((1, 2, 0)),
|
img.transpose((1, 2, 0)),
|
||||||
extent=list(coords.values())
|
extent=(left, right, bottom, top)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not geotiff.is_enabled():
|
if not geotiff.is_enabled():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue