Skip to content

Commit 5dcbce6

Browse files
authored
Add warning for radians flag with Proj class (#613)
1 parent 36f41ce commit 5dcbce6

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

pyproj/_transformer.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ cdef class _Transformer(Base):
424424
return
425425
if radians and self.is_pipeline:
426426
warnings.warn(
427-
"radian input with pipelines is not supported and may result "
428-
"in unexpected transformations."
427+
"radian input with pipelines is not supported in pyproj 2. "
428+
"support for raidans will be added in pyproj 3."
429429
)
430430

431431
tmp_pj_direction = _PJ_DIRECTION_MAP[TransformDirection.create(direction)]

pyproj/proj.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def __call__(
137137
latitude: Any,
138138
inverse: bool = False,
139139
errcheck: bool = False,
140+
radians: bool = False,
140141
) -> Tuple[Any, Any]:
141142
"""
142143
Calling a Proj class instance with the arguments lon, lat will
@@ -158,6 +159,11 @@ def __call__(
158159
inverse: boolean, optional
159160
If inverse is True the inverse transformation from x/y to
160161
lon/lat is performed. Default is False.
162+
radians: boolean, optional
163+
If True, will expect input data to be in radians and will return radians
164+
if the projection is geographic. Default is False (degrees).
165+
This does not work with pyproj 2 and is ignored. It will be enabled again
166+
in pyproj 3.
161167
errcheck: boolean, optional
162168
If True an exception is raised if the errors are found in the process.
163169
By default errcheck=False and ``inf`` is returned.
@@ -167,6 +173,11 @@ def __call__(
167173
Tuple[Any, Any]:
168174
The transformed coordinates.
169175
"""
176+
if radians:
177+
warnings.warn(
178+
"radian input is currently not supported in pyproj 2. "
179+
"Support for radian input will be added in pyproj 3."
180+
)
170181
# process inputs, making copies that support buffer API.
171182
inx, xisfloat, xislist, xistuple = _copytobuffer(longitude)
172183
iny, yisfloat, yislist, yistuple = _copytobuffer(latitude)

pyproj/transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def transform(
363363
radians: boolean, optional
364364
If True, will expect input data to be in radians and will return radians
365365
if the projection is geographic. Default is False (degrees). Ignored for
366-
pipeline transformations.
366+
pipeline transformations with pyproj 2, but will work in pyproj 3.
367367
errcheck: boolean, optional
368368
If True an exception is raised if the transformation is invalid.
369369
By default errcheck=False and an invalid transformation

test/test_proj.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,3 +522,9 @@ def test_numpy_bool_kwarg_true():
522522
proj="utm", zone=32, ellipsis="WGS84", datum="WGS84", units="m", south=south
523523
)
524524
assert "+south " in proj.srs
525+
526+
527+
def test_proj_radians_warning():
528+
proj = Proj("epsg:4326")
529+
with pytest.warns(UserWarning, match="radian"):
530+
proj(1, 2, radians=True)

test/test_transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,5 +738,5 @@ def test_pipeline_itransform(pipeline_str):
738738

739739
def test_pipeline_radian_transform_warning():
740740
trans = Transformer.from_pipeline("+proj=pipeline +ellps=GRS80 +step +proj=cart")
741-
with pytest.warns(UserWarning):
741+
with pytest.warns(UserWarning, match="radian"):
742742
trans.transform(0.1, 0.1, 0, radians=True)

0 commit comments

Comments
 (0)