Skip to content

Add warning for radians flag with Proj class #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproj/_transformer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ cdef class _Transformer(Base):
return
if radians and self.is_pipeline:
warnings.warn(
"radian input with pipelines is not supported and may result "
"in unexpected transformations."
"radian input with pipelines is not supported in pyproj 2. "
"support for raidans will be added in pyproj 3."
)

tmp_pj_direction = _PJ_DIRECTION_MAP[TransformDirection.create(direction)]
Expand Down
11 changes: 11 additions & 0 deletions pyproj/proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def __call__(
latitude: Any,
inverse: bool = False,
errcheck: bool = False,
radians: bool = False,
) -> Tuple[Any, Any]:
"""
Calling a Proj class instance with the arguments lon, lat will
Expand All @@ -158,6 +159,11 @@ def __call__(
inverse: boolean, optional
If inverse is True the inverse transformation from x/y to
lon/lat is performed. Default is False.
radians: boolean, optional
If True, will expect input data to be in radians and will return radians
if the projection is geographic. Default is False (degrees).
This does not work with pyproj 2 and is ignored. It will be enabled again
in pyproj 3.
errcheck: boolean, optional
If True an exception is raised if the errors are found in the process.
By default errcheck=False and ``inf`` is returned.
Expand All @@ -167,6 +173,11 @@ def __call__(
Tuple[Any, Any]:
The transformed coordinates.
"""
if radians:
warnings.warn(
"radian input is currently not supported in pyproj 2. "
"Support for radian input will be added in pyproj 3."
)
# process inputs, making copies that support buffer API.
inx, xisfloat, xislist, xistuple = _copytobuffer(longitude)
iny, yisfloat, yislist, yistuple = _copytobuffer(latitude)
Expand Down
2 changes: 1 addition & 1 deletion pyproj/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def transform(
radians: boolean, optional
If True, will expect input data to be in radians and will return radians
if the projection is geographic. Default is False (degrees). Ignored for
pipeline transformations.
pipeline transformations with pyproj 2, but will work in pyproj 3.
errcheck: boolean, optional
If True an exception is raised if the transformation is invalid.
By default errcheck=False and an invalid transformation
Expand Down
6 changes: 6 additions & 0 deletions test/test_proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,9 @@ def test_numpy_bool_kwarg_true():
proj="utm", zone=32, ellipsis="WGS84", datum="WGS84", units="m", south=south
)
assert "+south " in proj.srs


def test_proj_radians_warning():
proj = Proj("epsg:4326")
with pytest.warns(UserWarning, match="radian"):
proj(1, 2, radians=True)
2 changes: 1 addition & 1 deletion test/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,5 +738,5 @@ def test_pipeline_itransform(pipeline_str):

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