-
Notifications
You must be signed in to change notification settings - Fork 94
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
Wrong coordinates returned by AreaDefintion.get_lonlats
for some projections in out-of-Earth locations
#558
Comments
Nice find. Some comments:
|
Oh another question, if you take these out of bounds lon/lats and do the inverse calculation, do you get the same expected X/Y back? |
@djhoese no. |
Can you paste an example here that doesn't use pyresample and shows the results of the round trip (x/y -> lon/lat -> x/y)? Preferably only pyproj in the example would be awesome. |
Here it is @djhoese . A sample case for each of the problematic CRS.
This is the result:
|
Yeah I'm having trouble understanding this. I wouldn't be surprised if the answer for some projections is "yeah, it isn't 1:1, that's just the way it is". But for the first definition in your dict I can do the inverse transform of -10-50 million in the X direction and at the reference latitude (0) and get about the same -90 longitude: In [2]: crs = CRS.from_string('+proj=aeqd +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs +type=crs')
In [4]: transformer = Transformer.from_crs(crs.geodetic_crs, crs, always_xy=True)
In [12]: transformer.transform(-10000000, 0, direction="INVERSE")
Out[12]: (-89.83152841195214, 0.0)
In [13]: transformer.transform(-50000000, 0, direction="INVERSE")
Out[13]: (-89.15764205976068, 0.0) And somehow the -50M is closer to 0. But then doing the lon/lat by themselves shows that it should be closer to -10 million and going all the way to -175 longitude only gives -19 million.
Oh! It wraps: In [40]: transformer.transform(-20000000, 0, direction="INVERSE")
Out[40]: (-179.66305682390427, -0.0)
In [41]: transformer.transform(-21000000, 0, direction="INVERSE")
Out[41]: (171.35379033490054, -0.0)
In [42]: transformer.transform(-22000000, 0, direction="INVERSE")
Out[42]: (162.37063749370532, -0.0) |
In the context of #546, I was testing that the new boundary extraction methodology works for all projections available in cartopy, and I stumbled in wrong values returned by
AreaDefinition.get_lonlats()
.After a quick investigation, the error seems to arise from wrong results by
pyproj
transformations !Here below I provide a code that enable to visualize the wrong coordinates as well as snapshot of what is going on for some of the problematic projections.
Problem description
The wrong results occurs only for some CRS in out-of-Earth locations.
Usually
pyproj
returnsnp.inf
values in out-of-Earth locations, while with the projections listed below,AreaDefinition.get_lonlats()
returns wrong/bad longitude/latitude values. In a couple of cases, even returns latitudes outside the(-90, 90)
bounds.NOTE1: These errors causes wrong resampling with pyresample !
NOTE2: Note that for all cartopy projections not listed below, pyproj returns the correct results !
Expected Output
Usually
pyproj
returnsnp.inf
values in out-of-Earth locations.Code Sample, a minimal, complete, and verifiable piece of code
To further investigate the erroneous results, just take values in the lower left corner (which are out of Earth in the specified projections) and look at the returned values:
Examples
Equidistant Conic
Azimuthal Equidistant
Albers Equal Area
Equal Earth
Lamber Conformal
Sinusoidal
Eckert
The text was updated successfully, but these errors were encountered: