-
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
Better handling of anti-meridian cases #627
Comments
I'm not sure I understand all aspects of the problem. But from my limited view I would expect I made a quick test with an area def that goes from 120 to -120 degrees longitude. import pyresample
import numpy as np
def test_wrap(wrap_key, extent):
area_global = pyresample.create_area_def(
area_id="test",
projection={'datum': 'WGS84', 'proj': 'longlat'},
area_extent=[-180, -60, 180, 60],
resolution=60
)
area_wrapped = pyresample.create_area_def(
area_id="test",
projection={'datum': 'WGS84', wrap_key: 180.0, 'proj': 'longlat'},
area_extent=extent,
resolution=60
)
# Compute coordinates
lons, lats = area_wrapped.get_lonlats()
x, y = area_wrapped.get_proj_vectors()
# Resample fake data
data = np.ones(area_wrapped.shape)
resampled = pyresample.kd_tree.resample_nearest(area_wrapped, data, area_global, radius_of_influence=50000)
# Print results
print(lons)
print(x)
print(resampled) With
With
So the resampling obviously doesn't work. But what I like about |
Yeah, |
Hi @djhoese ! I just want to point out a few details I have in my notes that might help clarifying/solving this issue.
|
Hello. I admit I do not know exactly what this issue / enhancement is about. But since the antimeridian and data_reduce are mentioned, I would link to another github issue about these two topics from back in 2017. Maybe the topics are un-related, maybe the issue from 2017 should have been closed. But I know that I from time to time get unexpected behaviour with kdtree and grids having the pole / antimeridian. And that setting data_reduce to False is my quick fix. Sorry if I am off-topic here. |
Sorry for not following the template, but I'm not sure this fits.
Currently the
DynamicAreaDefinition.freeze
method has anantimeridian_mode
keyword argument that I added for handling cases where the provided lon/lats cross the anti-meridian (-180/180 in lonlat space). This kwarg can be:1 .
modify_crs
(default): Add a+pm=180
to shift the prime meridian of the projection to 180 degrees. This means the extents surround 0 instead of being discontinuous over -180/180. See downsides below.2.
modify_extents
: Mess with extents of lon/lat projections so the longitudes are 0-360 instead of a -180-180 range. See downsides below.3.
global_extents
: Change the extents to be the entire globe. Theoretically if resampling handling this properly you get a full globe with the input data split into two pieces.The
modify_crs
is problematic because many tools don't respect+pm=180
(see https://proj.org/en/9.5/usage/projections.html#prime-meridian). Themodify_extents
is a problem because it seems some (all?) of our resamplers can't handle longitudes outside the -180-180 range either deliberately filtering them as invalid (kdtree nearest neighbor does this) or suffering from PROJ transformation automatically wrapping longitudes to the -180-180 range.For these reasons I propose a few important changes:
modify_exents
and combine it withmodify_crs
, but at the same time changemodify_crs
to use+lon_wrap=180
instead of+pm=180
. See https://proj.org/en/9.5/usage/projections.html#longitude-wrapping which I think is what we normally want anyway.>=1e30
instead of doing the full -180/180 and -90/90 validation. This would allow PROJ to handle the wrapping.+lon_wrap=180
which I don't think is working right now.Questions:
get_lonlats
for an area return that has+lon_wrap=180
. Should it return 0-360 or -180/180 even though they wouldn't be contiguous? In the past I think we updated this method to assert that lon/lats are always -180/180.+pm=180
get us anything (is it useful to us or our users) that+lon_wrap=180
doesn't?The text was updated successfully, but these errors were encountered: