Commit 2251e5d4 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

The computation of the common extent in 3D geolayers now works properly if...


The computation of the common extent in 3D geolayers now works properly if target projection is not set to LonLat.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent b884b64d
Pipeline #8610 failed with stage
in 55 seconds
......@@ -28,8 +28,8 @@ from typing import Union, Tuple
import multiprocessing
import numpy as np
from py_tools_ds.geo.projection import WKT2EPSG, proj4_to_WKT
from py_tools_ds.geo.coord_trafo import get_proj4info
from py_tools_ds.geo.projection import WKT2EPSG, EPSG2WKT, proj4_to_WKT
from py_tools_ds.geo.coord_trafo import get_proj4info, transform_any_prj
from .transformer_2d import SensorMapGeometryTransformer, _corner_coords_lonlat_to_extent
from pyresample import AreaDefinition
......@@ -111,14 +111,32 @@ class SensorMapGeometryTransformer3D(object):
return data_mapgeo, out_gt, out_prj, kwargs_dict['band_idx']
def _get_common_target_extent(self, tgt_epsg):
if tgt_epsg == 4326:
corner_coords_ll = [[self.lons[0, 0, :].min(), self.lats[0, 0, :].max()], # common UL_xy
[self.lons[0, -1, :].max(), self.lats[0, -1, :].max()], # common UR_xy
[self.lons[-1, 0, :].min(), self.lats[-1, 0, :].min()], # common LL_xy
[self.lons[-1, -1, :].max(), self.lats[-1, -1, :].min()], # common LR_xy
]
tgt_extent = _corner_coords_lonlat_to_extent(corner_coords_ll, tgt_epsg)
common_tgt_extent = _corner_coords_lonlat_to_extent(corner_coords_ll, tgt_epsg)
else:
# get Lon/Lat corner coordinates of geolayers
UL_UR_LL_LR_ll = [(self.lons[y, x], self.lats[y, x]) for y, x in [(0, 0), (0, -1), (-1, 0), (-1, -1)]]
# transform them to target projection
UL_UR_LL_LR_prj = [transform_any_prj(EPSG2WKT(4326), EPSG2WKT(tgt_epsg), x, y) for x, y in UL_UR_LL_LR_ll]
# separate X and Y
X_prj, Y_prj = zip(*UL_UR_LL_LR_prj)
# 3D geolayers, i.e., the corner coordinates have multiple values for multiple bands
# -> use the outermost coordinates to be sure all data is included
X_prj = (X_prj[0].min(), X_prj[1].max(), X_prj[2].min(), X_prj[3].max())
Y_prj = (Y_prj[0].max(), Y_prj[1].max(), Y_prj[2].min(), Y_prj[3].min())
# get the extent
common_tgt_extent = (min(X_prj), min(Y_prj), max(X_prj), max(Y_prj))
return tgt_extent
return common_tgt_extent
def _get_common_area_definition(self,
data: np.ndarray,
......
Supports Markdown
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