Commit 58dc8f49 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed a bug which causes COREG.equalize_pixGrids() to run although the pixel...

Fixed a bug which causes COREG.equalize_pixGrids() to run although the pixel grids of reference and target image are equal. Fixed ResourceWarning in COREG.show_matchWin() as well as in COREG.calculate_spatial_shifts(). Fixed exception in COREG.view_CoRegPoints_folium() in case of a recent version of folium.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <>
parent 0d83bd9e
Pipeline #11698 failed with stage
in 3 minutes and 50 seconds
......@@ -52,7 +52,7 @@ from py_tools_ds.geo.coord_calc import get_corner_coordinates
from py_tools_ds.geo.vector.topology import get_overlap_polygon, get_smallest_boxImYX_that_contains_boxMapYX
from py_tools_ds.geo.projection import prj_equal, get_proj4info
from py_tools_ds.geo.vector.geometry import boxObj, round_shapelyPoly_coords
from py_tools_ds.geo.coord_grid import move_shapelyPoly_to_image_grid
from py_tools_ds.geo.coord_grid import move_shapelyPoly_to_image_grid, is_coord_grid_equal
from py_tools_ds.geo.coord_trafo import reproject_shapelyGeometry, mapXY2imXY, imXY2mapXY
from py_tools_ds.geo.raster.reproject import warp_ndarray
from py_tools_ds.geo.map_info import geotransform2mapinfo
......@@ -463,7 +463,8 @@ class COREG(object):
def equalize_pixGrids(self):
"""Equalize image grids and projections of reference and target image (align target to reference)."""
if not (prj_equal(self.ref.prj, self.shift.prj) and self.ref.xygrid_specs == self.shift.xygrid_specs):
if not (prj_equal(self.ref.prj, self.shift.prj) and
is_coord_grid_equal(, *self.shift.xygrid_specs)):
if not self.q:
print("Equalizing pixel grids and projections of reference and target image...")
......@@ -528,7 +529,7 @@ class COREG(object):
raise ImportError(
"This method requires the library 'holoviews'. It can be installed for Anaconda with "
"the shell command 'conda install -c ioam holoviews bokeh'.")
hv.Store.add_style_opts(hv.Image, ['vmin', 'vmax'])
......@@ -581,7 +582,6 @@ class COREG(object):
# Construct a HoloMap by defining the sampling on the Dimension
# dmap = hv.DynamicMap(image_slice, kdims=[hv.Dimension('z_axis', values=keys)])
return hmap
......@@ -1249,9 +1249,6 @@ class COREG(object):
if self.success is False:
return 'fail'
if self.q:
# set self.matchWin and self.otherWin (GeoArray instances)
self._get_image_windows_to_match() # 45-90ms
......@@ -1274,7 +1271,6 @@ class COREG(object):
if scps is None:
self.success = False
return 'fail'
......@@ -1364,8 +1360,6 @@ class COREG(object):
self._validate_ssim_improvement() # FIXME uses the not updated matchWin size
self.shift_reliability = self._calc_shift_reliability(scps)
return 'success'
def _get_updated_map_info(self):
......@@ -548,7 +548,9 @@ class COREG_LOCAL(object):
image=image2plot, bounds=[[lat_min, lon_min], [lat_max, lon_max]],
folium.GeoJson(self.CoRegPoints_table.loc[:, ['geometry', attribute2plot]]).add_to(map_osm)
points_values = self.CoRegPoints_table[['geometry', attribute2plot]] =
# add overlap polygon
overlapPoly = reproject_shapelyGeometry(self.COREG_obj.overlap_poly, self.im2shift.epsg, 4326)
......@@ -105,6 +105,7 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
def test_shift_calculation_with_image_coords_only(self):
"""Test with default parameters - should compute X/Y shifts properly and write the de-shifted target image."""
# FIXME fails when executed alone
# overwrite gt and prj
ref = GeoArray(self.ref_path)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment