13
13
:func:`addcyclic`: Add cyclic (wraparound) point in longitude.
14
14
"""
15
15
from distutils .version import LooseVersion
16
+
17
+ try :
18
+ from urllib import urlretrieve
19
+ from urllib2 import urlopen
20
+ except ImportError :
21
+ from urllib .request import urlretrieve , urlopen
22
+
16
23
from matplotlib import __version__ as _matplotlib_version
17
24
from matplotlib .cbook import is_scalar , dedent
18
25
# check to make sure matplotlib is not too old.
@@ -4051,7 +4058,6 @@ def warpimage(self,image="bluemarble",scale=None,**kwargs):
4051
4058
else :
4052
4059
newfile = False
4053
4060
if file .startswith ('http' ):
4054
- from urllib import urlretrieve
4055
4061
self ._bm_file , headers = urlretrieve (file )
4056
4062
else :
4057
4063
self ._bm_file = file
@@ -4211,7 +4217,6 @@ def arcgisimage(self,server='http://server.arcgisonline.com/ArcGIS',\
4211
4217
4212
4218
returns a matplotlib.image.AxesImage instance.
4213
4219
"""
4214
- import urllib2
4215
4220
if not hasattr (self ,'epsg' ):
4216
4221
msg = dedent ("""
4217
4222
Basemap instance must be creating using an EPSG code
@@ -4250,9 +4255,9 @@ def arcgisimage(self,server='http://server.arcgisonline.com/ArcGIS',\
4250
4255
f=image" % \
4251
4256
(server ,service ,xmin ,ymin ,xmax ,ymax ,self .epsg ,self .epsg ,xpixels ,ypixels ,dpi )
4252
4257
# print URL?
4253
- if verbose : print basemap_url
4258
+ if verbose : print ( basemap_url )
4254
4259
# return AxesImage instance.
4255
- return self .imshow (imread (urllib2 . urlopen (basemap_url )),ax = ax ,
4260
+ return self .imshow (imread (urlopen (basemap_url )),ax = ax ,
4256
4261
origin = 'upper' )
4257
4262
4258
4263
def wmsimage (self ,server ,\
@@ -4297,7 +4302,7 @@ def wmsimage(self,server,\
4297
4302
from owslib .wms import WebMapService
4298
4303
except ImportError :
4299
4304
raise ImportError ('OWSLib required to use wmsimage method' )
4300
- import urllib2 , io
4305
+ import io
4301
4306
ax = kwargs .pop ('ax' , None ) or self ._check_ax ()
4302
4307
if not hasattr (self ,'epsg' ):
4303
4308
msg = dedent ("""
@@ -4325,17 +4330,17 @@ def wmsimage(self,server,\
4325
4330
# ypixels not given, find by scaling xpixels by the map aspect ratio.
4326
4331
if ypixels is None :
4327
4332
ypixels = int (self .aspect * xpixels )
4328
- if verbose : print server
4333
+ if verbose : print ( server )
4329
4334
wms = WebMapService (server )
4330
4335
if verbose :
4331
- print 'id: %s, version: %s' % \
4332
- (wms .identification .type ,wms .identification .version )
4333
- print 'title: %s, abstract: %s' % \
4334
- (wms .identification .title ,wms .identification .abstract )
4335
- print 'available layers:'
4336
- print list (wms .contents )
4337
- print 'projection options:'
4338
- print wms [kwargs ['layers' ][0 ]].crsOptions
4336
+ print ( 'id: %s, version: %s' %
4337
+ (wms .identification .type ,wms .identification .version ))
4338
+ print ( 'title: %s, abstract: %s' %
4339
+ (wms .identification .title ,wms .identification .abstract ))
4340
+ print ( 'available layers:' )
4341
+ print ( list (wms .contents ) )
4342
+ print ( 'projection options:' )
4343
+ print ( wms [kwargs ['layers' ][0 ]].crsOptions )
4339
4344
# remove keys from kwargs that are over-ridden
4340
4345
for k in ['format' ,'bbox' ,'service' ,'size' ,'srs' ]:
4341
4346
if 'format' in kwargs : del kwargs ['format' ]
@@ -4347,7 +4352,7 @@ def wmsimage(self,server,\
4347
4352
return self .imshow (imread (io .BytesIO (img .read ()),
4348
4353
format = format ),origin = 'upper' ,alpha = alpha ,ax = ax )
4349
4354
# this works for png, but not jpeg
4350
- #return self.imshow(imread(urllib2. urlopen(img.url),format=format),origin='upper')
4355
+ #return self.imshow(imread(urlopen(img.url),format=format),origin='upper')
4351
4356
4352
4357
def drawmapscale (self ,lon ,lat ,lon0 ,lat0 ,length ,barstyle = 'simple' ,\
4353
4358
units = 'km' ,fontsize = 9 ,yoffset = None ,labelstyle = 'simple' ,\
@@ -5095,7 +5100,7 @@ def _addcyclic_lon(a):
5095
5100
if len (arr ) == 1 :
5096
5101
return _addcyclic_lon (arr [- 1 ])
5097
5102
else :
5098
- return map (_addcyclic ,arr [:- 1 ]) + [_addcyclic_lon (arr [- 1 ])]
5103
+ return list ( map (_addcyclic ,arr [:- 1 ]) + [_addcyclic_lon (arr [- 1 ])])
5099
5104
5100
5105
def _choosecorners (width ,height ,** kwargs ):
5101
5106
"""
0 commit comments