Commit 2097bab5 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed issue #47 (COREG_LOCAL.view_CoRegPoints() raises KeyError: 'X_SHIFT_M'...

Fixed issue #47

 (COREG_LOCAL.view_CoRegPoints() raises KeyError: 'X_SHIFT_M' error when there are too many clouds). Increased default figsize of COREG_LOCAL.view_CoRegPoints().
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 9d235f12
Pipeline #15618 passed with stage
in 2 minutes and 24 seconds
......@@ -378,7 +378,7 @@ class COREG_LOCAL(object):
options are 'ref' and 'tgt' (default: 'tgt')
:param hide_filtered: <bool> hide all points that have been filtered out according to tie point filter
level
:param figsize: <tuple> size of the figure to be viewed, e.g. (10,10)
:param figsize: <tuple> size of the figure to be viewed, e.g. (10, 10)
:param title: <str> plot title
:param vector_scale: <float> scale factor for shift vector length (default: 1 -> no scaling)
:param savefigPath:
......@@ -390,6 +390,7 @@ class COREG_LOCAL(object):
:return:
"""
from matplotlib import pyplot as plt # noqa
from matplotlib.offsetbox import AnchoredText
from cartopy.crs import PlateCarree
from mpl_toolkits.axes_grid1 import make_axes_locatable
......@@ -397,9 +398,16 @@ class COREG_LOCAL(object):
if backgroundIm not in ['tgt', 'ref']:
raise ValueError('backgroundIm')
backgroundIm = self.im2shift if backgroundIm == 'tgt' else self.imref
fig, ax = backgroundIm.show_map(figsize=figsize, nodataVal=self.nodata[1], return_map=True,
fig, ax = backgroundIm.show_map(figsize=figsize,
nodataVal=self.nodata[1],
return_map=True,
band=self.COREG_obj.shift.band4match)
# make sure the output figure has a reasonable size, also if figsize is not given
if not figsize:
w, h = fig.get_size_inches()
fig.set_size_inches(w * 1.6, h * 1.6)
# set figure title
dict_attr_title = dict(
X_WIN_SIZE='size of the matching window in x-direction [pixels]',
......@@ -425,6 +433,7 @@ class COREG_LOCAL(object):
raise ValueError(attribute2plot, "Invalid value for 'attribute2plot'. Valid values are: %s."
% ", ".join(self.CoRegPoints_table.columns))
if not self.CoRegPoints_table.empty:
# get GeoDataFrame containing everything needed for plotting
outlierCols = [c for c in self.CoRegPoints_table.columns if 'OUTLIER' in c]
attr2include = ['geometry', attribute2plot] + outlierCols + ['X_SHIFT_M', 'Y_SHIFT_M']
......@@ -526,8 +535,19 @@ class COREG_LOCAL(object):
divider.new_vertical(size="2%", pad=0.4, pack_start=False, axes_class=plt.Axes)
else:
msg = "The map does not contain any tie points \n" \
"because all the found tie points were flagged as false-positives."
ax.add_artist(AnchoredText(msg, loc='lower center', prop=dict(c='r')))
if not self.q:
warnings.warn(msg)
else:
msg = "The map does not contain any tie points because no tie points were found at all."
ax.add_artist(AnchoredText(msg, loc='lower center', prop=dict(c='r')))
if not self.q:
warnings.warn('Cannot plot any tie point because none is left after tie point validation.')
warnings.warn(msg)
if savefigPath:
fig.savefig(savefigPath, dpi=savefigDPI)
......
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