Created
October 6, 2014 23:28
-
-
Save spacelis/fa17cb4aa26f80edce65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- __init__.old.py 2014-10-07 01:26:24.682034979 +0200 | |
+++ __init__.py 2014-10-07 01:26:30.558034775 +0200 | |
@@ -4272,7 +4272,7 @@ | |
return self.imshow(imread(urllib2.urlopen(basemap_url)),origin='upper') | |
def wmsimage(self,server,\ | |
- xpixels=400,ypixels=None,\ | |
+ xpixels=400,ypixels=None,togray=False,\ | |
format='png',verbose=False,**kwargs): | |
""" | |
Retrieve an image using from a WMS server using the | |
@@ -4357,8 +4357,14 @@ | |
srs='EPSG:%s' % self.epsg, **kwargs) | |
# return AxesImage instance. | |
# this works for png and jpeg. | |
- return self.imshow(imread(io.BytesIO(urllib2.urlopen(img.url).read()), | |
- format=format),origin='upper') | |
+ im = imread(io.BytesIO(urllib2.urlopen(img.url).read()), | |
+ format=format) | |
+ if togray and im.shape[2] >= 3: | |
+ gray = 0.3 * im[:,:,0] + 0.6 * im[:,:,1] + 0.1 * im[:,:,2] | |
+ im[:,:,0] = gray | |
+ im[:,:,1] = gray | |
+ im[:,:,2] = gray | |
+ return self.imshow(im,origin='upper') | |
# this works for png, but not jpeg | |
#return self.imshow(imread(urllib2.urlopen(img.url),format=format),origin='upper') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment