-
Hi I am seeing the below issue where the first call to transform fails but after that it seems to return the expected values. Does someone know what is going on here and how I can avoid it? Thanks! from pyproj import Transformer
import numpy as np
t1 =Transformer.from_crs("EPSG:4326", "ESRI:102008", always_xy=True)
coords = np.array([[-90.166259, 32.546644]])
t1.transform(coords[:, 0], coords[:, 1]) # fails
t1.transform(coords[:, 0], coords[:, 1]) # works? Python 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:04:44) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyproj import Transformer
>>> import numpy as np
>>> t1 =Transformer.from_crs("EPSG:4326", "ESRI:102008", always_xy=True)
>>> coords = np.array([[-90.166259, 32.546644]])
>>> t1.transform(coords[:, 0], coords[:, 1]) # fails
(array([inf]), array([inf]))
>>> t1.transform(coords[:, 0], coords[:, 1]) # works?
(array([522352.71447431]), array([-857684.1764726]))
>>> |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
Here are some suggestions for debugging: |
Beta Was this translation helpful? Give feedback.
-
Does it fail using PROJ command line |
Beta Was this translation helpful? Give feedback.
-
As mentioned in #705 "I believe the problem may be caused by some incorrect CA on my machine " , it seems to be a network issue. You should see something similar using |
Beta Was this translation helpful? Give feedback.
-
I'm often working in offline environments. So failing to get the grids from the internet with any number of errors is expected. How pyproj handles that environment is something to consider however as I am sure there are others in similar environments. I'm just guessing here but it seems like pyproj/PROJ transform looks for the online grids and there is an error (request hangs or is otherwise blocked) and pyproj blindly fails on that transform. The second time around, pyproj tries without the network support and provides a transformation. It would be great if that catch/switch would happen within the first transform call - ideally throwing a warning letting users know that the network grid support failed and the transformation may be less precise than with the grids. |
Beta Was this translation helpful? Give feedback.
Pre-downloading the grids may help: https://pyproj4.github.io/pyproj/stable/transformation_grids.html