Skip to content

Commit

Permalink
fix pyproj 3.6.1 api changed
Browse files Browse the repository at this point in the history
  • Loading branch information
HowcanoeWang committed Dec 28, 2023
1 parent a15fcbb commit 76d9ff4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions easyidp/geotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,21 @@ def convert_proj3d(points_np, crs_origin, crs_target, is_xyz=True):
points_np, is_single = is_single_point(points_np)

# check unit to know if is (lon, lat, lat) -> degrees or (x, y, z) -> meters
x_unit = crs_origin.coordinate_system.axis_list[0].unit_name
y_unit = crs_origin.coordinate_system.axis_list[1].unit_name
if crs_origin.coordinate_system is not None:
# suitable for pyproj > 3.4.0 < 3.6.0
x_unit = crs_origin.coordinate_system.axis_list[0].unit_name
y_unit = crs_origin.coordinate_system.axis_list[1].unit_name
elif crs_origin.axis_info is not None:
# suitable for pyproj > 3.6.1
x_unit = crs_origin.axis_info[0].unit_name
y_unit = crs_origin.axis_info[1].unit_name
else:
raise AttributeError(
f'The API of pyproj to get axis unit may changed at current {pyproj.__version__}.'
f'Unable to find at both "crs.coordinate_system.axis_list" (pyproj < 3.6.0) '
f'and "crs.axis_info" (pyproj > 3.6.0), please report this issue or downgrade your pyproj version to 3.6.1'
)

if x_unit == "degree" and y_unit == "degree":
is_xyz = False
else:
Expand Down

0 comments on commit 76d9ff4

Please sign in to comment.