Commit cd0e951b authored by Daniel Scheffler's avatar Daniel Scheffler

First attempt to provide compatibility to other projections than UTM and LonLat.

Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 93084700
Pipeline #11990 failed with stage
in 6 minutes and 55 seconds
......@@ -305,16 +305,19 @@ class Tie_Point_Grid(object):
if isLocal(self.COREG_obj.shift.prj):
crs = None
elif isProjectedOrGeographic(self.COREG_obj.shift.prj) == 'geographic':
crs = dict(ellps='WGS84', datum='WGS84', proj='longlat')
elif isProjectedOrGeographic(self.COREG_obj.shift.prj) == 'projected':
UTMzone = abs(get_UTMzone(prj=self.COREG_obj.shift.prj))
south = get_UTMzone(prj=self.COREG_obj.shift.prj) < 0
crs = dict(ellps='WGS84', datum='WGS84', proj='utm', zone=UTMzone, south=south, units='m', no_defs=True)
if not south:
del crs['south']
else:
crs = None
from pyproj import CRS
crs = CRS(self.COREG_obj.shift.epsg)
# elif isProjectedOrGeographic(self.COREG_obj.shift.prj) == 'geographic':
# crs = dict(ellps='WGS84', datum='WGS84', proj='longlat')
# elif isProjectedOrGeographic(self.COREG_obj.shift.prj) == 'projected':
# UTMzone = abs(get_UTMzone(prj=self.COREG_obj.shift.prj))
# south = get_UTMzone(prj=self.COREG_obj.shift.prj) < 0
# crs = dict(ellps='WGS84', datum='WGS84', proj='utm', zone=UTMzone, south=south, units='m', no_defs=True)
# if not south:
# del crs['south']
# else:
# crs = None
GDF = GeoDataFrame(index=range(len(geomPoints)), crs=crs,
columns=['geometry', 'POINT_ID', 'X_IM', 'Y_IM', 'X_UTM', 'Y_UTM'])
......@@ -374,7 +377,7 @@ class Tie_Point_Grid(object):
bar.print_progress(percent=numberDone / len(GDF) * 100)
if results.ready():
# <= this is the line where multiprocessing can freeze if an exception appears within
# COREG ans is not raised
# COREG and is not raised
results = results.get()
break
......
......@@ -33,6 +33,7 @@ from pkgutil import find_loader
from .cases import test_cases
from arosics import COREG_LOCAL
from geoarray import GeoArray
from py_tools_ds.geo.projection import EPSG2WKT
class COREG_LOCAL_init(unittest.TestCase):
......@@ -99,6 +100,43 @@ class CompleteWorkflow_INTER1_S2A_S2A(unittest.TestCase):
self.assertTrue(os.path.exists(self.coreg_kwargs['path_out']),
'Output of local co-registration has not been written.')
def test_calculation_of_tie_point_grid_noWGS84(self):
ref = GeoArray(self.ref_path).to_mem()
tgt = GeoArray(self.tgt_path).to_mem()
# ref.filePath = None
# tgt.filePath = None
# ref.reproject_to_new_grid(tgt_prj=3035, tgt_xygrid=[[0, 30], [0, -30]])
# tgt.reproject_to_new_grid(tgt_prj=3035, tgt_xygrid=[[0, 30], [0, -30]])
# force to overwrite projection
ref.filePath = None
tgt.filePath = None
ref.prj = EPSG2WKT(3035) # ETRS89_LAEA_Europe
tgt.prj = EPSG2WKT(3035) # ETRS89_LAEA_Europe
# get instance of COREG_LOCAL object
CRL = COREG_LOCAL(ref, tgt, **self.coreg_kwargs)
# use the getter of the CoRegPoints_table to calculate tie point grid
# noinspection PyStatementEffect
CRL.CoRegPoints_table
# test tie point grid visualization
if find_loader('mpl_toolkits.basemap'): # only works if basemap is installed
CRL.view_CoRegPoints(hide_filtered=True)
CRL.view_CoRegPoints(hide_filtered=False)
CRL.view_CoRegPoints(shapes2plot='vectors')
if find_loader('folium') and find_loader('geojson'):
CRL.view_CoRegPoints_folium()
# test shift correction and output writer
CRL.correct_shifts()
self.assertTrue(os.path.exists(self.coreg_kwargs['path_out']),
'Output of local co-registration has not been written.')
def test_calculation_of_tie_point_grid_float_coords(self):
# NOTE: This does not test against unequaly sized output of get_image_windows_to_match().
......
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