Skip to content

Commit

Permalink
Add epsg_mesh_transformation option for slf_base
Browse files Browse the repository at this point in the history
  • Loading branch information
lucduron committed Feb 23, 2024
1 parent f6af747 commit c2aea09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cli/slf_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- shift time series
"""

from pyproj import Transformer
import sys
from tqdm import tqdm

Expand All @@ -24,12 +25,21 @@ def slf_base(args):
resin.get_time()

output_header = resin.header.copy()
# Shift mesh coordinates if necessary
# Shift and transform mesh coordinates (change EPSG) if necessary
if args.shift:
output_header.transform_mesh([Transformation(0, 1, 1, args.shift[0], args.shift[1], 0)])
if args.epsg_mesh_transformation:
old_x, old_y = output_header.x, output_header.y
new_x, new_y = Transformer.from_crs("EPSG:%i" % args.epsg_mesh_transformation[0],
"EPSG:%i" % args.epsg_mesh_transformation[1]).transform(old_x, old_y)
output_header.x_stored = new_x
output_header.y_stored = new_y

# Set mesh origin coordinates
if args.set_mesh_origin:
output_header.set_mesh_origin(args.set_mesh_origin[0], args.set_mesh_origin[1])
else:
output_header.set_mesh_origin(0, 0)

# Toggle output file endianness if necessary
if args.toggle_endianness:
Expand Down Expand Up @@ -74,6 +84,8 @@ def slf_base(args):
parser = PyTelToolsArgParse(description=__doc__, add_args=['in_slf', 'out_slf', 'shift'])

parser.add_argument('--set_mesh_origin', type=int, nargs=2, help='Mesh origin coordinates (x, y)', metavar=('X', 'Y'))
parser.add_argument('--epsg_mesh_transformation', type=int, nargs=2,
help='Mesh transformation from IN_EPSG to OUT_EPSG (with pyproj)', metavar=('IN_EPSG', 'OUT_EPSG'))

group_var = parser.add_argument_group('Serafin variables (optional)',
'See variables abbrevations on https://github.com/CNR-Engineering/PyTelTools/wiki/Notations-of-variables')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ coloredlogs
descartes
matplotlib
numpy
pyproj
PyQt5
pyshp>=2.0
pytest
Expand Down

0 comments on commit c2aea09

Please sign in to comment.