-
Notifications
You must be signed in to change notification settings - Fork 20
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
Remove special handling of geographic (longlat) CRSes #98
Conversation
Fixes handling of lon/lat CRSes that don't have a prime meridian at 0. It also removes the assumption that all lon/lat projections are equal.
4d7e83c
to
8be4d2e
Compare
@djhoese @mraspaud I installed with pip and tried this PR with the lonlat area (using pm: 180) as you proposed here #95 (comment) and I get the old problem of horizontal scratches that I already solved one year ago. Did I miss something? |
Yes and no. This PR fixes the issue that current pycoast would treat all lon/lat projections the same. So if you did something with I was going to save fixing this for another PR. |
No problem. All you have to do is take pm: 170 (as I explained for my OPC MSLP projections 2022) and shift the area extent by 10° in x direction. It must be noted that the same result can be achieved today (without PR) with projection eqc and area in meters. The scratch problem you see above in my image is caused by the 0° meridian the antimeridian of 180° that is crossing Spain where the coastlines are part of the huge Eurasia polygon. If you move pm: (seems to be the same as lon_0) to 170°, then the (-10°) antimeridian does not cut the Eurasia shape. I still think we should let the solution for the scratch problem as is though it cannot handle all possible cases (with very big areas). This is similar with resampling that also fails with a couple of available projections. |
This is not about finding a workaround for a use case, but fixing the library not supporting something it should logically support. As for the solution, it becomes just another condition in the indexing function. I have a fix for it but it makes a few assumptions so I didn't make a PR yet. As for resampling, what projections? In pyresample? |
@djhoese I have never used 'lonlat' as a projection name before. So I even didn't realize there was a problem here. RESAMPLING: In this thread I found that only the "nearest" resampler worked as expected for all my LEO images. Except for Mollweide (moll) even the "nearest" resampler seems to fail for pseudoconic projections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree here. From what I understand, this PR finds the resolution at the equator, while the previous version use the location of the area to find the correct local resolution. This is important for areas far from the equator, where the resolution computation would yield very different results.
@mraspaud This PR is much more than the change in the resolution helper function. But as for the new resolution guessing logic (ex. Additionally, this resolution guessing for So while this may not be the most accurate and I'm fine changing it if you have suggestions (use the polar radius? use the minimum of the arc length calculation with the polar and equatorial radius? other?), this only changes how long/lat projections are handled and it didn't work prior to this anyway. Existing metered projection handling should be the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
Just one last question before we merge: do we have an image comparison test for a latlong area?
No. I thought about that, but realized that I didn't technically need to for this particular set of changes as I'm just making sure that the different projection parameters have an effect on the final result. If you want one I can make one. Just more stuff to include the sdist/wheel and the repository. |
Yes, I think one test image would be good, close to one of the poles would be better. |
@mraspaud Added. Ready for re-review and merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This includes fixing handling of lon/lat projections that didn't have a prime meridian at 0 (of the traditional prime meridian sense). This also means that we now properly treat lon/lat projections as not equal. As part of this, Pycoast had a special Proj class for backwards compatibility with pyproj that has been removed. Lastly, the one place that we need to know if something is lon/lat or in a metered projection was in the "from config" overlay logic where it got a default resolution based on the AreaDefinition's resolution. This has been updated to perform logic based on the units of the CRS, not just on it being geographic or not.
NOTE: This PR is based on #96 so there are a lot of commits. I can rebase this after that PR is merged.
CC @lobsiger
git diff origin/main **/*py | flake8 --diff