Skip to content
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

Transformer with MercatorAConversion with lat/lon of natural origin returns ProjError #1089

Closed
kdpenner opened this issue Jun 7, 2022 · 14 comments · Fixed by #1095
Closed
Labels

Comments

@kdpenner
Copy link
Contributor

kdpenner commented Jun 7, 2022

latlon_crs = CRS("EPSG:4326")
conv = MercatorAConversion(latitude_natural_origin=0.1, longitude_natural_origin=0.1)
merc_crs = ProjectedCRS(conversion=conv)
transform_func = Transformer.from_crs(latlon_crs, merc_crs, always_xy=True).transform

Problem description

The above code returns ProjError: Input is not a transformation. If latitude_natural_origin=0 and longitude_natural_origin=0, no error is returned.

Expected Output

No error.

Environment Information

  • Output from: pyproj -v
pyproj info:
    pyproj: 3.3.1
      PROJ: 9.0.0
  data dir: /Users/kpenner/dev/pyproj/share/proj
user_data_dir: /Users/kpenner/Library/Application Support/proj
PROJ DATA (recommended version): 1.9
PROJ Database: 1.2
EPSG Database: v10.054 [2022-02-13]
ESRI Database: ArcMap 12.9 [2022-02-18]
IGNF Database: 3.1.0 [2019-05-24]

System:
    python: 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:45:10) [Clang 12.0.1 ]
executable: /Users/kpenner/dev/pyproj/bin/python
   machine: macOS-12.4-x86_64-i386-64bit

Python deps:
/Users/kpenner/dev/pyproj/lib/python3.10/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
   certifi: 2022.05.18.1
    Cython: None
setuptools: 62.3.2
       pip: 22.1.2

Installation method

  • conda

Conda environment information


Environment (conda list):
# Name                    Version                   Build  Channel
proj                      9.0.0                h2364a93_1    conda-forge
pyproj                    3.3.1           py310h6c09501_0    conda-forge

Details about conda and system ( conda info ):

     active environment : pyproj
    active env location : /Users/kpenner/dev/pyproj
            shell level : 2
       user config file : /Users/kpenner/.condarc
 populated config files : /Users/kpenner/.condarc
          conda version : 4.12.0
    conda-build version : not installed
         python version : 3.7.12.final.0
       virtual packages : __osx=10.16=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /Users/kpenner/miniconda3  (writable)
      conda av data dir : /Users/kpenner/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/kpenner/miniconda3/pkgs
                          /Users/kpenner/.conda/pkgs
       envs directories : /Users/kpenner/dev
                          /Users/kpenner/miniconda3/envs
                          /Users/kpenner/.conda/envs
               platform : osx-64
             user-agent : conda/4.12.0 requests/2.27.1 CPython/3.7.12 Darwin/21.5.0 OSX/10.16
                UID:GID : 501:20
             netrc file : None
           offline mode : False
@kdpenner kdpenner added the bug label Jun 7, 2022
@snowman2
Copy link
Member

snowman2 commented Jun 9, 2022

projinfo -s 'PROJCRS["undefined",BASEGEOGCRS["undefined",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ID["EPSG",6326]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8901]]],CONVERSION["unknown",METHOD["Mercator (variant A)",ID["EPSG",9804]],PARAMETER["Latitude of natural origin",0.1,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0.1,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",1,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],LENGTHUNIT["metre",1,ID["EPSG",9001]]],AXIS["(N)",north,ORDER[2],LENGTHUNIT["metre",1,ID["EPSG",9001]]]]' -t 'EPSG:4326' -o PROJ
Candidate operations found: 1
-------------------------------------
Operation No. 1:

unknown id, Inverse of unknown, 0 m, unknown domain of validity

PROJ string:
Error when exporting to PROJ string: Unsupported value for Latitude of natural origin

@snowman2
Copy link
Member

snowman2 commented Jun 9, 2022

@snowman2
Copy link
Member

snowman2 commented Jun 9, 2022

>>> MercatorAConversion(longitude_natural_origin=10).to_proj4()
'+proj=merc +lon_0=10 +k=1 +x_0=0 +y_0=0'
>>> MercatorAConversion(latitude_natural_origin=10).to_proj4()

@snowman2
Copy link
Member

snowman2 commented Jun 9, 2022

It seems that the PROJ only supports latitude_natural_origin=0.

@snowman2
Copy link
Member

snowman2 commented Jun 9, 2022

@snowman2
Copy link
Member

snowman2 commented Jun 9, 2022

Related to #1036, would be good to raise an exception when exporting to PROJ string if NULL is returned.

@kdpenner
Copy link
Contributor Author

kdpenner commented Jun 9, 2022

What's the reason for keeping latitude_natural_origin as a kwarg if only 0 is supported?

On an unrelated note, the lat_ts PROJ parameter is unsupported by pyproj.

@snowman2
Copy link
Member

snowman2 commented Jun 9, 2022

What's the reason for keeping latitude_natural_origin as a kwarg if only 0 is supported?

For completeness sake when creating CRS and exporting to WKT. This may be needed even if PROJ does not support it for transformations.

On an unrelated note, the lat_ts PROJ parameter is unsupported by pyproj.

See MercatorBConversion

@snowman2
Copy link
Member

https://epsg.org/coord-operation-method_9804/Mercator-variant-A.html

Note: For the Mercator variant A (1SP) method, in the EPSG Dataset, to be fully transparent about the location of the projection origin, the parameter "latitude of natural origin (LatO)" is included in the defining parameters of the map projection method and map projections. It must have a value of zero because by definition the location of the natural origin for this method is on the equator. However this parameter is not used in the conversion formulas.

Seems like it should always be 0. I am thinking a check on latitude_natural_origin when building the CRS to ensure it is 0 makes sense.

@snowman2 snowman2 added this to To do in 3.4.0 Release via automation Jun 25, 2022
@kdpenner
Copy link
Contributor Author

Makes sense to me. I'd also note the constraint in the documentation.

@snowman2
Copy link
Member

Sounds good to me. A PR with the change is welcome.

@kdpenner
Copy link
Contributor Author

Happy to submit a PR soon. Should a warning be raised if a non-zero latitude_natural_origin is passed?

@snowman2
Copy link
Member

snowman2 commented Jun 27, 2022

Happy to submit a PR soon. Should a warning be raised if a non-zero latitude_natural_origin is passed?

Thanks! I am thinking since it is invalid, a CRSError should be raised in the initialization around here.

@snowman2 snowman2 moved this from To do to In progress in 3.4.0 Release Jul 5, 2022
3.4.0 Release automation moved this from In progress to Done Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants