Skip to content

Commit 81d5881

Browse files
authored
DOC: Update transform_bounds docstring about antimeridian response (#949)
1 parent 4ff849a commit 81d5881

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

pyproj/transformer.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ def transform( # pylint: disable=invalid-name
659659
instead of returning a new array. This will fail if the input
660660
is not an array in C order with the double data type.
661661
662-
Example:
662+
Example
663+
--------
663664
664665
>>> from pyproj import Transformer
665666
>>> transformer = Transformer.from_crs("epsg:4326", "epsg:3857")
@@ -769,7 +770,8 @@ def itransform(
769770
Default is :attr:`pyproj.enums.TransformDirection.FORWARD`.
770771
771772
772-
Example:
773+
Example
774+
--------
773775
774776
>>> from pyproj import Transformer
775777
>>> transformer = Transformer.from_crs(4326, 2100)
@@ -875,6 +877,25 @@ def transform_bounds(
875877
Transform boundary densifying the edges to account for nonlinear
876878
transformations along these edges and extracting the outermost bounds.
877879
880+
If the destination CRS is geographic and right < left then the bounds
881+
crossed the antimeridian. In this scenario there are two polygons,
882+
one on each side of the antimeridian. The first polygon should be
883+
constructed with (left, bottom, 180, top) and the second with
884+
(-180, bottom, top, right).
885+
886+
To construct the bounding polygons with shapely::
887+
888+
def bounding_polygon(left, bottom, right, top):
889+
if right < left:
890+
return shapely.geometry.MultiPolygon(
891+
[
892+
shapely.geometry.box(left, bottom, 180, top),
893+
shapely.geometry.box(-180, bottom, right, top),
894+
]
895+
)
896+
return shapely.geometry.box(left, bottom, right, top)
897+
898+
878899
Parameters
879900
----------
880901
left: float

0 commit comments

Comments
 (0)