Commit a885f52c authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Tie_Point_Grid: added type hints. DeShifter: cleaned up.

parent 7e67c0d2
......@@ -578,7 +578,7 @@ class COREG_LOCAL(object):
min_points_local_corr=min_points_local_corr,
resamp_alg=self.rspAlg_DS,
cliptoextent=cliptoextent,
# clipextent = self.im2shift.box.boxMapYX,
# clipextent=self.im2shift.box.boxMapYX,
progress=self.progress,
v=self.v,
q=self.q)
......
......@@ -300,49 +300,6 @@ class DESHIFTER(object):
else: # FIXME equal_prj==False ist noch NICHT implementiert
"""RESAMPLING NEEDED"""
# if self.warpAlg=='GDAL_cmd':
# warnings.warn('This method has not been tested in its current state!')
# # FIX ME nicht multiprocessing-fähig,
# # FIX ME weil immer kompletter array gewarpt wird und sich ergebnisse gegenseitig überschreiben
# # create tempfile
# fd, path_tmp = tempfile.mkstemp(prefix='AROSICS', suffix=self.outFmt, dir=self.tempDir)
# os.close(fd)
#
# t_extent = " -te %s %s %s %s" %self._get_out_extent()
# xgsd, ygsd = self.out_gsd
# cmd = "gdalwarp -r %s -tr %s %s -t_srs '%s' -of %s %s %s -srcnodata %s -dstnodata %s -overwrite%s"\
# %(self.rspAlg, xgsd,ygsd,self.ref_prj,self.outFmt,self.im2shift.filePath,
# path_tmp, self.nodata, self.nodata, t_extent)
# out, exitcode, err = subcall_with_output(cmd)
#
# if exitcode!=1 and os.path.exists(path_tmp):
# """update map info, arr_shifted, geotransform and projection"""
# ds_shifted = gdal.OpenShared(path_tmp) if self.outFmt == 'VRT' else gdal.Open(path_tmp)
# self.shift_gt, self.shift_prj = ds_shifted.GetGeoTransform(), ds_shifted.GetProjection()
# self.updated_map_info = geotransform2mapinfo(self.shift_gt,self.shift_prj)
#
# print('reading from', ds_shifted.GetDescription())
# if self.band2process is None:
# dim2RowsColsBands = \
# lambda A: np.swapaxes(np.swapaxes(A,0,2),0,1) # rasterio.open(): [bands,rows,cols]
# self.arr_shifted = dim2RowsColsBands(rasterio.open(path_tmp).read())
# else:
# self.arr_shifted = rasterio.open(path_tmp).read(self.band2process)
#
# self.GeoArray_shifted = GeoArray(self.arr_shifted,tuple(self.shift_gt), self.shift_prj)
# self.is_shifted = True
# self.is_resampled = True
#
# ds_shifted = None
# [gdal.Unlink(p) for p in [path_tmp] if os.path.exists(p)] # delete tempfiles
# else:
# print("\n%s\nCommand was: '%s'" %(err.decode('utf8'),cmd))
# [gdal.Unlink(p) for p in [path_tmp] if os.path.exists(p)] # delete tempfiles
# self.tracked_errors.append(RuntimeError('Resampling failed.'))
# raise self.tracked_errors[-1]
#
# # TO DO implement output writer
# FIXME avoid reading the whole band if clip_extent is passed
in_arr = self.im2shift[:, :, self.band2process] \
......
......@@ -27,6 +27,8 @@ from py_tools_ds.processing.progress_mon import ProgressBar
from py_tools_ds.geo.vector.conversion import points_to_raster
from geoarray import GeoArray
from .CoReg import GeoArray_CoReg
__author__ = 'Daniel Scheffler'
global_shared_imref = None
......@@ -94,7 +96,7 @@ class Tie_Point_Grid(object):
if not isinstance(COREG_obj, COREG):
raise ValueError("'COREG_obj' must be an instance of COREG class.")
self.COREG_obj = COREG_obj
self.COREG_obj = COREG_obj # type: COREG
self.grid_res = grid_res
self.max_points = max_points
self.outFillVal = outFillVal
......@@ -107,26 +109,29 @@ class Tie_Point_Grid(object):
self.q = q if not v else False # overridden by v
self.progress = progress if not q else False # overridden by q
self.ref = self.COREG_obj.ref
self.shift = self.COREG_obj.shift
self.ref = self.COREG_obj.ref # type: GeoArray_CoReg
self.shift = self.COREG_obj.shift # type: GeoArray_CoReg
self.XY_points, self.XY_mapPoints = self._get_imXY__mapXY_points(self.grid_res)
self._CoRegPoints_table = None # set by self.CoRegPoints_table
self._GCPList = None # set by self.to_GCPList()
self.kriged = None # set by Raster_using_Kriging()
mean_x_shift_px = property(lambda self:
self.CoRegPoints_table['X_SHIFT_PX'][
self.CoRegPoints_table['X_SHIFT_PX'] != self.outFillVal].mean())
mean_y_shift_px = property(lambda self:
self.CoRegPoints_table['Y_SHIFT_PX'][
self.CoRegPoints_table['Y_SHIFT_PX'] != self.outFillVal].mean())
mean_x_shift_map = property(lambda self:
self.CoRegPoints_table['X_SHIFT_M'][
self.CoRegPoints_table['X_SHIFT_M'] != self.outFillVal].mean())
mean_y_shift_map = property(lambda self:
self.CoRegPoints_table['Y_SHIFT_M'][
self.CoRegPoints_table['Y_SHIFT_M'] != self.outFillVal].mean())
@property
def mean_x_shift_px(self):
return self.CoRegPoints_table['X_SHIFT_PX'][self.CoRegPoints_table['X_SHIFT_PX'] != self.outFillVal].mean()
@property
def mean_y_shift_px(self):
return self.CoRegPoints_table['Y_SHIFT_PX'][self.CoRegPoints_table['Y_SHIFT_PX'] != self.outFillVal].mean()
@property
def mean_x_shift_map(self):
return self.CoRegPoints_table['X_SHIFT_M'][self.CoRegPoints_table['X_SHIFT_M'] != self.outFillVal].mean()
@property
def mean_y_shift_map(self):
return self.CoRegPoints_table['Y_SHIFT_M'][self.CoRegPoints_table['Y_SHIFT_M'] != self.outFillVal].mean()
@property
def CoRegPoints_table(self):
......
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