Closed miniufo closed 1 year ago
If you add always_xy=True
, it works:
>>> from pyproj import Proj, Transformer
>>> s = "+ellps=sphere +a=6370000 +b=6370000 +proj=lcc +lon_0=103.0 +lat_0=30.1 +x_0=0.0 +y_0=0.0 +lat_1=40.0 +lat_2=25.0 +no_defs"
>>> transformer = Transformer.from_crs('WGS84', s)
>>> transformer = Transformer.from_crs('WGS84', s, always_xy=True)
>>> e, n = transformer.transform(102.0, 30.1, errcheck=True)
>>> e, n
(-95450.8134071046, 448.8443216748683)
The reason is because CRS axis order is respected in transformations with PROJ 6+ pyproj 2+. For WSG84
, latitude is expected to be first:
>>> from pyproj import CRS
>>> CRS("WGS84")
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
See getting started example.
Code Sample, a copy-pastable example if possible
A "Minimal, Complete and Verifiable Example" will make it much easier for maintainers to help you: http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
Problem description
This code snippet raises an error:
Expected Output
No
Environment Information
Installation method
Conda environment information (if you installed with conda):
Environment (
conda list
):Details about
conda
and system (conda info
):