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
Imshow keyword arg 'origin' issue #359
Comments
This must be related to #358, if not the same bug. It sure looks similar. |
OK I've nailed down the weird origin behaviour. When the image is interpolated so that it can be displayed on the new projection there is an implicit assumption that the image array is structured from lower left to upper right, meaning that the regridded image is wrong if it is in fact upper left to lower right. Adding this after L744 in geoaxes.py gives the expected behaviour: if kwargs['origin'] == 'upper':
# we implicitly assume the orientation is lower when we regrid
img = img[::-1]
kwargs['origin'] = 'lower' However, this does not solve the artefacts outside of the expected domain... I shall see if I can locate that problem before making a PR as they may well be related issues. |
OK I think I have this one sorted, the artefacts at the edges of the plot are due to the nearest neighbour interpolation routine not masking off points outside the original image. I'll try and put a PR together soon and update here. |
Nice one 👍 |
Thanks for the comprehensive bug report @dkillick. |
When plotting an image on a set of Cartopy geoaxes with a native projection not equal to the image's projection, an issue with the origin keyword argument becomes apparent. This kwarg has two options; 'upper' and 'lower', where 'upper' should be appropriate for images (such as jpegs or geotiffs) that define an origin in the upper-left corner of the image.
It can be shown that this kwarg is not being interpreted correctly by using an example from the Cartopy docs: http://scitools.org.uk/cartopy/docs/latest/matplotlib/advanced_plotting.html#images with the following minor changes:
The changes made here are altering the axes projection to Miller and setting the axes extent to global, the combination of which makes the issue evident.
To demonstrate the issue, removing the array manipulation when
img
is made and changing the origin kwarg's value toupper
moves the position of the image from the correct location (generated by the code above), to a location of appropriate longitude but incorrect latitude. This may be seen much more clearly by comparing the two images found below, whereorigin='upper'
is set in the top image, butorigin='lower'
(with appropriate array manipulation) is set in the lower.The text was updated successfully, but these errors were encountered: