diff --git a/src/mintpy/prep_hyp3.py b/src/mintpy/prep_hyp3.py index 6fbbf6b35..d9282a3a5 100644 --- a/src/mintpy/prep_hyp3.py +++ b/src/mintpy/prep_hyp3.py @@ -14,7 +14,7 @@ ######################################################################### -def add_hyp3_metadata(fname,meta,is_ifg=True): +def add_hyp3_metadata(fname, meta, is_ifg=True): '''Read/extract attribute data from HyP3 metadata file and add to metadata dictionary Inputs: *unw_phase.tif, *corr.tif file name, *dem.tif, *inc_map.tif, e.g. @@ -57,6 +57,10 @@ def add_hyp3_metadata(fname,meta,is_ifg=True): S = N + float(meta['Y_STEP']) * int(meta['LENGTH']) E = W + float(meta['X_STEP']) * int(meta['WIDTH']) + # convert UTM to lat/lon + N, W = ut.utm2latlon(meta, W, N) + S, E = ut.utm2latlon(meta, E, S) + if meta['ORBIT_DIRECTION'] == 'ASCENDING': meta['LAT_REF1'] = str(S) meta['LAT_REF2'] = str(S) diff --git a/src/mintpy/tropo_pyaps3.py b/src/mintpy/tropo_pyaps3.py index cd992066b..9a91162fc 100644 --- a/src/mintpy/tropo_pyaps3.py +++ b/src/mintpy/tropo_pyaps3.py @@ -279,8 +279,8 @@ def get_bounding_box(meta, geom_file=None): # e.g. meters for UTM projection from ASF HyP3 y_unit = meta.get('Y_UNIT', 'degrees').lower() if not y_unit.startswith('deg'): - lat0, lon0 = ut.to_latlon(meta['OG_FILE_PATH'], lon0, lat0) - lat1, lon1 = ut.to_latlon(meta['OG_FILE_PATH'], lon1, lat1) + lat0, lon0 = ut.utm2latlon(meta, easting=lon0, northing=lat0) + lat1, lon1 = ut.utm2latlon(meta, easting=lon1, northing=lat1) else: # radar coordinates @@ -561,10 +561,6 @@ def calc_delay_timeseries(inps): # for lookup table in geo-coded (gamma, roipac) and obs. in geo-coord inps.lat, inps.lon = ut.get_lat_lon(geom_obj.metadata) - # convert coordinates to lat/lon, e.g. from UTM for ASF HyPP3 - if not geom_obj.metadata.get('Y_UNIT', 'degrees').startswith('deg'): - inps.lat, inps.lon = ut.to_latlon(inps.atr['OG_FILE_PATH'], inps.lon, inps.lat) - else: # for lookup table in geo-coded (gamma, roipac) and obs. in radar-coord inps.lat, inps.lon = ut.get_lat_lon_rdc(inps.atr) diff --git a/src/mintpy/utils/utils.py b/src/mintpy/utils/utils.py index fc3ae6b13..3c83f0cbe 100644 --- a/src/mintpy/utils/utils.py +++ b/src/mintpy/utils/utils.py @@ -465,8 +465,8 @@ def prepare_geo_los_geometry(geom_file, unit='rad'): E = W + x_step * width # SNWE in meter --> degree - lat0, lon0 = to_latlon(atr['OG_FILE_PATH'], W, N) - lat1, lon1 = to_latlon(atr['OG_FILE_PATH'], E, S) + lat0, lon0 = utm2latlon(atr, W, N) + lat1, lon1 = utm2latlon(atr, E, S) lat_step = (lat1 - lat0) / length lon_step = (lon1 - lon0) / width diff --git a/src/mintpy/utils/utils0.py b/src/mintpy/utils/utils0.py index 76d5c1fba..b5523358a 100644 --- a/src/mintpy/utils/utils0.py +++ b/src/mintpy/utils/utils0.py @@ -403,6 +403,7 @@ def get_lat_lon(meta, geom_file=None, box=None, dimension=2, ystep=1, xstep=1): # UTM to lat/lon if not meta['Y_UNIT'].startswith('deg') and 'UTM_ZONE' in meta.keys(): + print('UTM coordinates detected, convert UTM into lat/lon') lats, lons = utm2latlon(meta, easting=lons, northing=lats) else: