Commit f242ed2d authored by Gaetano Raffaele's avatar Gaetano Raffaele

FIX: revert to old coregister module + use EPSG:4326 for intermediate products

parent 7035c83d
......@@ -22,7 +22,7 @@ def main(argv):
sys.exit("Platform not supported!")
try:
opts, args = getopt.getopt(argv, '', ['band-ref=', 'band-in=', 'step=', 'minstep=', 'minpoints=', 'maxpoints=', 'prec=', 'outsrs='])
opts, args = getopt.getopt(argv, '', ['band-ref=', 'band-in=', 'step=', 'minstep=', 'minpoints=', 'maxpoints=', 'prec='])
except getopt.GetoptError as err:
print str(err)
......@@ -30,13 +30,13 @@ def main(argv):
src = args[1]
ds = gdal.Open(args[1])
prj = ds.GetProjection()
#prj = ds.GetProjection()
gt = ds.GetGeoTransform()
srs = osr.SpatialReference()
srs.ImportFromWkt(prj)
code = srs.GetAuthorityCode(None)
code_out = code
#srs = osr.SpatialReference()
#srs.ImportFromWkt(prj)
#code = srs.GetAuthorityCode(None)
gsp = str(int(2 * round(max(abs(gt[1]), abs(gt[5])))))
ds = None
vhrb = 3
hrb = 3
......@@ -47,7 +47,6 @@ def main(argv):
enough = 20
prec = 3
maxgcp = -1
out_epsg = None
for opt, val in opts:
if opt == '--band-ref':
......@@ -64,8 +63,6 @@ def main(argv):
maxgcp = int(val)
elif opt == '--prec':
prec = float(val)
elif opt == '--outsrs':
code_out = val
tmphomo = randomword(16) + '.geom'
tmpfld = os.path.split(args[1])[0] + '/' + randomword(16) + '/'
......@@ -119,7 +116,7 @@ def main(argv):
ds.SetProjection('')
ds = None
cmd = ['otbcli_OrthoRectification', '-io.in \"' + args[1] + '?&geom=' + tmphomo + '\"', '-io.out', tmpfld + 'sits_band_coreg.tif', 'uint16', '-map', 'epsg', '-map.epsg.code', code_out, '-opt.gridspacing', gsp]
cmd = ['otbcli_OrthoRectification', '-io.in \"' + args[1] + '?&geom=' + tmphomo + '\"', '-io.out', tmpfld + 'sits_band_coreg.tif', 'uint16', '-map', 'epsg', '-map.epsg.code', '4326', '-opt.gridspacing', gsp]
cmdex = ' '.join(cmd)
subprocess.call(cmdex, shell=True)
......@@ -147,7 +144,7 @@ def main(argv):
ds.SetProjection('')
ds = None
cmd = ['otbcli_OrthoRectification', '-io.in \"' + f + '?&geom=' + tmphomo + '\"', '-io.out', tmpfld + fn[0] + '_coreg.tif', 'uint8', '-map', 'epsg', '-map.epsg.code', code_out, '-opt.gridspacing', gsp, '-interpolator nn']
cmd = ['otbcli_OrthoRectification', '-io.in \"' + f + '?&geom=' + tmphomo + '\"', '-io.out', tmpfld + fn[0] + '_coreg.tif', 'uint8', '-map', 'epsg', '-map.epsg.code', '4326', '-opt.gridspacing', gsp, '-interpolator nn']
cmdex = ' '.join(cmd)
subprocess.call(cmdex, shell=True)
......@@ -174,6 +171,6 @@ def main(argv):
if __name__ == '__main__':
if len(sys.argv) < 2:
sys.exit(
'Usage: python coregister.py [--band-ref <target ref band>] [--band-in <source band>] [--step <geobins initial step def. 256>] [--minstep <geobins minimum step def. 16>] [--minpoints <minimum # of homologous points def. 40>] [--maxpoints <maximum # of GCP points def. -1 unlimited> [--prec <colocalisation precision in pixels] [--outsrs <EPSG code for output>] <vhsr scene file> <stack to coregister>')
'Usage: python coregister.py [--band-ref <target ref band>] [--band-in <source band>] [--step <geobins initial step def. 256>] [--minstep <geobins minimum step def. 16>] [--minpoints <minimum # of homologous points def. 40>] [--maxpoints <maximum # of GCP points def. -1 unlimited> [--prec <colocalisation precision in pixels] <vhsr scene file> <stack to coregister>')
else:
main(sys.argv[1:])
......@@ -289,7 +289,7 @@ def main(argv):
if not os.path.exists(ref_S2) or force_coreg:
cmd = ['otbcli_Superimpose', '-inr', refl, '-inm', ms_file, '-out', ref_S2, 'uint16']
subprocess.call(cmd, shell=sh)
cmd = ['python', 'coregister.py', '--band-ref', vhrbnd, '--band-in', bnd, '--maxpoints', str(mxp), '--outsrs', dst_srs_code, ref_S2, refl]
cmd = ['python', 'coregister.py', '--band-ref', vhrbnd, '--band-in', bnd, '--maxpoints', str(mxp), ref_S2, refl]
subprocess.call(cmd, shell=sh)
# Sentinel-2 THEIA
......
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