Commit 063c8835 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Some adjustments to recent changes in py_tools_ds and pyproj. Added pyproj as...


Some adjustments to recent changes in py_tools_ds and pyproj. Added pyproj as direct dependency to requirements. Updated HISTORY.rst and version info.
Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 71ff4941
Pipeline #12140 failed with stages
in 2 minutes and 57 seconds
......@@ -2,6 +2,13 @@
History
=======
0.4.2 (2020-09-01)
------------------
* Some adjustments to recent changes in py_tools_ds and pyproj.
* Added pyproj as direct dependency to requirements.
0.4.1 (2020-08-17)
------------------
......
......@@ -32,8 +32,8 @@ from time import sleep
import numpy as np
import gdal
from py_tools_ds.geo.projection import EPSG2WKT, WKT2EPSG, proj4_to_WKT, proj4_to_dict
from py_tools_ds.geo.coord_trafo import get_proj4info, transform_coordArray, transform_any_prj
from pyproj import CRS
from py_tools_ds.geo.coord_trafo import transform_coordArray, transform_any_prj
from py_tools_ds.geo.coord_calc import corner_coord_to_minmax, get_corner_coordinates
from py_tools_ds.geo.coord_grid import find_nearest
from py_tools_ds.io.raster.writer import write_numpy_to_image
......@@ -145,7 +145,7 @@ class SensorMapGeometryTransformer(object):
"""
# get the target extent if not given
# (this also makes sure that create_area_def does not return a DynamicAreaDefinition)
tgt_epsg = WKT2EPSG(proj4_to_WKT(get_proj4info(proj=tgt_prj)))
tgt_epsg = CRS(tgt_prj).to_epsg()
tgt_extent = tgt_extent or self._get_target_extent(tgt_epsg)
if tgt_res:
......@@ -159,7 +159,7 @@ class SensorMapGeometryTransformer(object):
# passing LonLats and resolution
area_definition = \
create_area_def(area_id='',
projection=get_proj4info(proj=tgt_prj),
projection=CRS(tgt_prj).to_dict(),
area_extent=tgt_extent,
resolution=tgt_res)
......@@ -189,7 +189,7 @@ class SensorMapGeometryTransformer(object):
# xy_coords = np.dstack([self.swath_definition.lons[::10, ::10],
# self.swath_definition.lats[::10, ::10]])
else:
xy_coords = np.dstack(list(transform_coordArray(EPSG2WKT(4326), EPSG2WKT(tgt_epsg),
xy_coords = np.dstack(list(transform_coordArray(CRS(4326).to_wkt(), CRS(tgt_epsg).to_wkt(),
self.swath_definition.lons,
self.swath_definition.lats)))
write_numpy_to_image(xy_coords, path_xycoords, 'ENVI')
......@@ -214,7 +214,7 @@ class SensorMapGeometryTransformer(object):
"LINE_OFFSET": "0",
"PIXEL_STEP": "1",
"LINE_STEP": "1",
"SRS": EPSG2WKT(tgt_epsg),
"SRS": CRS(tgt_epsg).to_wkt(),
}, "GEOLOCATION")
vrt.FlushCache()
del ds_data, vrt
......@@ -260,7 +260,7 @@ class SensorMapGeometryTransformer(object):
area_definition = AreaDefinition(area_id='',
description='',
proj_id='',
projection=get_proj4info(proj=tgt_prj),
projection=CRS(tgt_prj),
width=x_size,
height=y_size,
area_extent=list(out_extent),
......@@ -321,13 +321,7 @@ class SensorMapGeometryTransformer(object):
float, float, float], str):
gt = area_definition.area_extent[0], area_definition.pixel_size_x, 0, \
area_definition.area_extent[3], 0, -area_definition.pixel_size_y
with warnings.catch_warnings():
# suppress a UserWarning coming from pyresample v0.15.0
warnings.filterwarnings('ignore', category=UserWarning,
message='You will likely lose important projection information when converting '
'to a PROJ string from another format.')
proj4_str = area_definition.proj_str
prj = proj4_to_WKT(proj4_str)
prj = area_definition.crs_wkt
return gt, prj
......@@ -366,7 +360,7 @@ class SensorMapGeometryTransformer(object):
if not tgt_prj:
raise ValueError(tgt_prj, 'Target projection must be given if area_definition is not given.')
tgt_epsg = WKT2EPSG(proj4_to_WKT(get_proj4info(proj=tgt_prj)))
tgt_epsg = CRS(tgt_prj).to_epsg()
tgt_extent = tgt_extent or self._get_target_extent(tgt_epsg)
if tgt_coordgrid:
......@@ -400,10 +394,8 @@ class SensorMapGeometryTransformer(object):
:param src_prj: projection of the input map geometry array (WKT or 'epsg:1234' or <EPSG_int>)
:param src_extent: extent coordinates of input map geometry array (LL_x, LL_y, UR_x, UR_y) in the src_prj
"""
proj4_args = proj4_to_dict(get_proj4info(proj=src_prj))
# get area_definition
self.area_definition = AreaDefinition('', '', '', proj4_args, data.shape[1], data.shape[0],
self.area_definition = AreaDefinition('', '', '', CRS(src_prj), data.shape[1], data.shape[0],
list(src_extent))
# resample
......@@ -423,7 +415,7 @@ class SensorMapGeometryTransformer(object):
def _corner_coords_lonlat_to_extent(corner_coords_ll: List, tgt_epsg: int):
corner_coords_tgt_prj = [transform_any_prj(EPSG2WKT(4326), EPSG2WKT(tgt_epsg), x, y)
corner_coords_tgt_prj = [transform_any_prj(4326, tgt_epsg, x, y)
for x, y in corner_coords_ll]
corner_coords_tgt_prj_np = np.array(corner_coords_tgt_prj)
x_coords = corner_coords_tgt_prj_np[:, 0]
......
......@@ -28,8 +28,8 @@ from typing import Union, Tuple
import multiprocessing
import numpy as np
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 pyproj import CRS
from py_tools_ds.geo.coord_trafo import transform_any_prj
from .transformer_2d import \
SensorMapGeometryTransformer, _corner_coords_lonlat_to_extent, \
......@@ -128,7 +128,7 @@ class SensorMapGeometryTransformer3D(object):
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]
UL_UR_LL_LR_prj = [transform_any_prj(4326, 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)
......@@ -154,7 +154,7 @@ class SensorMapGeometryTransformer3D(object):
tgt_coordgrid: Tuple[Tuple, Tuple] = None
) -> AreaDefinition:
# get common target extent
tgt_epsg = WKT2EPSG(proj4_to_WKT(get_proj4info(proj=tgt_prj)))
tgt_epsg = CRS(tgt_prj).to_epsg()
tgt_extent = tgt_extent or self._get_common_target_extent(tgt_epsg, tgt_coordgrid=tgt_coordgrid)
SMGT2D = SensorMapGeometryTransformer(lons=self.lons[:, :, 0], # does NOT affect the computed area definition
......
......@@ -37,7 +37,7 @@ version = {}
with open("sensormapgeo/version.py") as version_file:
exec(version_file.read(), version)
requirements = ['numpy', 'gdal', 'pyresample>=1.11.0', 'py_tools_ds>=0.14.26']
requirements = ['numpy', 'gdal', 'pyresample>=1.11.0', 'py_tools_ds>=0.14.26', 'pyproj>=2.2']
setup_requirements = []
......
......@@ -10,12 +10,12 @@ dependencies:
- gdal
- conda-forge::libgdal # force to use conda-forge for libgdal to avoid package version incompatiblies due to mixed channels (libkea.so.1.4.7: cannot open shared object file: No such file or directory)
- pyresample>=1.11.0
- pyproj>=2.2
# py_tools_ds
- pyqt
- scikit-image
- rasterio
- pyproj
- lxml
- geopandas
- ipython
......
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