matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
780 stars 392 forks source link

No background map from arcgisimage #481

Closed tonino0013 closed 2 years ago

tonino0013 commented 4 years ago

Dear All, I am working with Python3.5.2 with matplotlib '3.0.3' version, my basemap version is the 1.1.0. I have an Ubuntu 16.04 Laptop. I have this code (to plot a seismic epicenter over the background map from arcgisimage server):

m = Basemap(projection='mill', llcrnrlon=-70.20, llcrnrlat=-30.00, urcrnrlon=-56.90, urcrnrlat=-9.10,
            resolution='c',epsg= 4326, ax=ax1)
m.arcgisimage(service='World_Topo_Map', xpixels = 2000, verbose= False)
m.drawcoastlines()
m.drawcountries(color='yellow',linewidth=2.7)
m.drawmeridians(np.arange(0, 360, 2.5), labels=[True,False,False,True])
m.drawparallels(np.arange(-90, 90, 2.5),labels=[False,True,True,False])

with open(epi) as f:
    reader=csv.reader(f, delimiter=';')
    next(reader)
    for uhu in reader:
        lat.append(float(uhu[0]))
        lon.append(float(uhu[1]))
        mag.append(float(uhu[2]))
        depth.append(float(uhu[3]))

min_marker_size = 1.7
for lons, lats, mags in zip(lon, lat, mag):
    x,y = m(lons, lats)
    msize = mags * min_marker_size
    m.plot(x, y, 'ro', markersize=msize)

plt.show()

Under Windows 10 this code works nice and I can see the wonderful background map, however at Linux O.S. I am not able to see the background map, is this an issue of matplotlib or basemap?.

The first figure is taken from Win10, the second figure is taken from Ubuntu16.04

Regards,

basemap_Windows10

basamap_Ubuntu

WeatherGod commented 4 years ago

That is odd. I wouldn't expect a difference in behavior between OSes. If you set verbose to True, do you see error or warning messages on Ubuntu?

On Fri, Dec 27, 2019 at 11:32 AM Gonzalo Antonio Fernandez Marañon < notifications@github.com> wrote:

Dear All, I am working with Python3.5.2 with matplotlib '3.0.3' version, my basemap version is the 1.1.0. I have an Ubuntu 16.04 Laptop. I have this code (to plot a seismic epicenter over the background map from arcgisimage server):

m = Basemap(projection='mill', llcrnrlon=-70.20, llcrnrlat=-30.00, urcrnrlon=-56.90, urcrnrlat=-9.10, resolution='c',epsg= 4326, ax=ax1) m.arcgisimage(service='World_Topo_Map', xpixels = 2000, verbose= False) m.drawcoastlines() m.drawcountries(color='yellow',linewidth=2.7) m.drawmeridians(np.arange(0, 360, 2.5), labels=[True,False,False,True]) m.drawparallels(np.arange(-90, 90, 2.5),labels=[False,True,True,False])

with open(epi) as f: reader=csv.reader(f, delimiter=';') next(reader) for uhu in reader: lat.append(float(uhu[0])) lon.append(float(uhu[1])) mag.append(float(uhu[2])) depth.append(float(uhu[3]))

min_marker_size = 1.7 for lons, lats, mags in zip(lon, lat, mag): x,y = m(lons, lats) msize = mags * min_marker_size m.plot(x, y, 'ro', markersize=msize)

plt.show()

Under Windows 10 this code works nice and I can see the wonderful background map, however at Linux O.S. I am not able to see the background map, is this an issue of matplotlib or basemap?.

The first figure is taken from Win10, the second figure is taken from Ubuntu16.04

Regards,

[image: basemap_Windows10] https://user-images.githubusercontent.com/9260897/71524578-92bf9c80-28a4-11ea-9379-45c8827793ab.png

[image: basamap_Ubuntu] https://user-images.githubusercontent.com/9260897/71524647-c995b280-28a4-11ea-8c68-105fd5ac64e1.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/481?email_source=notifications&email_token=AACHF6AXSNS6CWSDOAP6X53Q2YU3RA5CNFSM4J76VW32YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IC4M5NA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACHF6FTPNCKSROTB2FKPTLQ2YU3RANCNFSM4J76VW3Q .

tonino0013 commented 4 years ago

Dear @WeatherGod ,

I saw just a warning updating the 'verbose=True'

FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method.
  return _prepare_from_string(" ".join(pjargs))
http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/export?bbox=-4022.163721818379,-1718.8733853924696,-3260.129854294384,-521.3915935690491&bboxSR=4326&imageSR=4326&size=2000,3142&dpi=96&format=png32&transparent=true&f=image

The link under my Ubuntu 16.04 it is just an empty image Thank you for your time. Tonino

FMassin commented 4 years ago

I have the same issue on Mac OSX...

vc1492a commented 3 years ago

Same here, on macOS 10.15.7 (Catalina) Python 3.8 Matplotlib version 3.2.1.

molinav commented 3 years ago

@vc1492a I think this issue could be the same one as in #499 and the current master already includes the bugfix. Which basemap version are you using?

vc1492a commented 3 years ago

@molinav thanks for the prompt reply - after some more diagnosis ended up being an unrelated issue, thanks!

molinav commented 2 years ago

I am closing this issue because the problem in the OP is actually solved now. The key point is the traceback of the URL:

http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/export?bbox=-4022.163721818379,-1718.8733853924696,-3260.129854294384,-521.3915935690491&bboxSR=4326&imageSR=4326&size=2000,3142&dpi=96&format=png32&transparent=true&f=image

where the bounding box should contain "standard" latitudes and longitudes (since the OP uses EPSG 4326), but instead it contains out-of-bound values due to an unexpected radian-to-degree conversion factor applied inside Basemap.arcgisimage before generating the URL.

This problem was fixed in PR #505 by @guziy, but this PR introduced a new bug in any projection different from "cyl". This new bug was finally fixed in PR #548 and released with basemap version 1.3.4.