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

Why is the vertical axis flipped sometimes? #1

Closed
philipbaileynar opened this issue Mar 1, 2021 · 7 comments
Closed

Why is the vertical axis flipped sometimes? #1

philipbaileynar opened this issue Mar 1, 2021 · 7 comments

Comments

@philipbaileynar
Copy link

We are calling py3DEP with geoJSON polygon boundaries and sometimes the data are returned with the vertical axis flipped. Here is an example:

https://github.com/Riverscapes/riverscapes-tools/blob/3dep/packages/rscontext/research/3dep_testing.ipynb

This only happens sometimes and we can't figure out the pattern as to why. Any advice would be appreciated!

@cheginit
Copy link
Collaborator

cheginit commented Mar 1, 2021

Thanks for providing the example notebook.

The issue seems to be with matplotlib, since when I plot them with xarray itself, it looks fine:
image

image

@KellyMWhitehead
Copy link

Thank you for the quick response!

I still seem to be having reversed y values when I save the array to geotiff.

I will admit I have not used xarrays much, but when I look at the y coordinates they do appear to be in reversed order between the 10m and 1.1m dems:
image

@cheginit
Copy link
Collaborator

cheginit commented Mar 1, 2021

Ah, I see what you mean. This is a known issue with xarray.merge, you can check it here.
Py3DEP, under-the-hood, decomposes large requests into smaller chunks then merge the results before returning it to the user. The 10-km resolution doesn't need any decomposition so the data is returned without any need for merging but 1-km resolution has to be decomposed and then merged which leads to this issue.
A quick fix for this case is to sort the 1-km dataset to match that of the 10-km dataset:
image

@cheginit
Copy link
Collaborator

cheginit commented Mar 1, 2021

Since the PR on xarray is still open, I will push a temporary fix for Py3DEP until the PR in xarray gets merged.

cheginit pushed a commit that referenced this issue Mar 1, 2021
@cheginit
Copy link
Collaborator

cheginit commented Mar 1, 2021

@philipbaileynar and @KellyMWhitehead, thanks for opening the issue. I pushed a fix, you can either update Py3DEP using pip install --no-deps -U git+https://github.com/cheginit/py3dep to get the fix or use the sort method that I mentioned earlier until I officially release a new version (probably by the end of the next week).

cheginit pushed a commit to hyriver/pygeoutils that referenced this issue Mar 2, 2021
@cheginit
Copy link
Collaborator

cheginit commented Mar 2, 2021

I addressed issue in the upstream package, PyGeoUtils, so you can install the fix by updating that package instead, i.e. pip install --no-deps -U git+https://github.com/cheginit/pygeoutils or, as I said, just sort it manually and wait for the upcoming official release.

@cheginit
Copy link
Collaborator

Since the issue is resolved, I will close it. Please feel free to reopen if you still have the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants