-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix rasterio example in docs #1881
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
Conversation
LGTM. Thanks @fmaussion. I had noticed this was broken but hadn't figured out why yet. |
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.
thanks!
da = xr.open_rasterio('RGB.byte.tif') | ||
|
||
# Normalize the image | ||
da = da / 255 |
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 don't think this is strictly necessary with RGB support in imshow, though I suppose it doesn't hurt.
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.
That's unfortunately necessary, see #1880
doc/gallery/plot_rasterio_rgb.py
Outdated
|
||
# Plot on a map | ||
ax = plt.subplot(projection=crs) | ||
da.plot.imshow(ax=ax, transform=crs) |
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.
For pedagogical purposes, it might be nice to explicitly write rga='band'
.
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.
yes, will do
OK, LGTM
…On Fri, Feb 2, 2018 at 10:57 AM Fabien Maussion ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In doc/gallery/plot_rasterio_rgb.py
<#1881 (comment)>:
> +
+import os
+import urllib.request
+import xarray as xr
+import cartopy.crs as ccrs
+import matplotlib.pyplot as plt
+
+# Download the file from rasterio's repository
+url = 'https://github.com/mapbox/rasterio/raw/master/tests/data/RGB.byte.tif'
+urllib.request.urlretrieve(url, 'RGB.byte.tif')
+
+# Read the data
+da = xr.open_rasterio('RGB.byte.tif')
+
+# Normalize the image
+da = da / 255
That's unfortunately necessary, see #1880
<#1880>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1881 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABKS1nkIbFX5Fez6jbcpsykDaC6_s1ZJks5tQ1pDgaJpZM4R3GRI>
.
|
Thanks! |
#1796 introduced a bug in the doc gallery. This PR reverts the code to the previous greyscale example and adds a new case using imshow (the use case is different, as I tried to explain in the descriptions).
I also took care of #1789 (comment) : the docs should now build even when rasterio is not installed.
cc @Zac-HD , @shoyer