-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
[Bug]: Issue overlaying geographic vector data on geographic raster data #23704
Comments
A bit more context and working example that may be of use. First question I have is: can anyone else reproduce this behaviour? Here's an issue that puts in context of open source teaching materials: geocompx/geocompy#83 |
I can reproduce it. Although I do not have any insights into the problem, I can confirm that the (I used the qt-backend and current |
Thanks for reproducing it. Just to clarify, do you get the upside-down New Zealand result? |
Ohh, it is actually doing the "right" thing. The image has a range of about 1000, while the outline has a range of about 1000000, with an offset. Also, the yaxis is inverted somewhere. So zoom in to the top left corner and the image will appear. |
Pass the rasterio object transform as an argument to the From rasterio docs. Clue is originally the axis labels are going from 0 to (max image height) - ie plotting as pixels rather than the desired coordinates, so need the transform. |
Many thanks @Rabscuttler this is awesome! Demo of the fix: # Plot combined
fig, ax = pyplot.subplots(figsize=(15, 15))
rasterio.plot.show(nz_elev_read, ax=ax, transform=nz_elev.transform);
nz_transformed.plot(ax=ax, facecolor='none', edgecolor='r'); # fails |
Also see matplotlib/matplotlib#23704
Bug summary
I have 2 datasets in the same CRS. They plot fine individually. But when you try to plot one on top of another it fails.
Code for reproduction
Actual outcome
Expected outcome
The overlay between the two images below
Additional information
Illustration of this issue built on reproducible CI on GitHub actions: https://geocompr.github.io/py/09-mapping.html
Operating system
Ubuntu
Matplotlib Version
3.1.2
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.8.10 and 3.9
Jupyter version
?
Installation
conda
The text was updated successfully, but these errors were encountered: