1

Hi I tried to plot a map with scale bar.

However, there is a problem with drawmapscale part.

The code is as below.

    la=36.25
    ua=36.6
    ln=128.1
    un=129
    m_lat=(la+ua)/2
    m_lon=(ln+un)/2
    mmap=pd.read_csv('altitude_of_area.csv')
    x=mmap.X.to_list()
    y=mmap.Y.to_list()
    z=mmap.altitude.to_list()
    m=Basemap(projection='lcc', lat_0=m_lat, lon_0=m_lon, resolution='f', llcrnrlon=ln, urcrnrlon=un, urcrnrlat=ua, epsg=4326)
    m.scatter(x,y,c=z, cmap=plt.get_cmap('Greys'), s=0.5, vmin=0)
    x, y=m(x_m,y_m)
    lon_tlst=np.linspace(ln, un, 5)
    lat_tlst=np.linspace(la, ua, 5)
    m.drawparallels(lat_tlst, labels=[1,0,0,0], fontsize=25)
    m.drawmeridians(lon_tlst, labels=[0,0,0,1], fontsize=25)
    m.drawmapscale(lat=la+0.01,lon=ua-0.04, length=15, lat0=(la+ua)/2, lon0=(ln+un)/2, barstyle='fancy', fontsize=25, fontcolor='k', yoffset=15*25, zorder=10)

When I run this code, it shows the error as below.

Valueerror: cannot draw map scale for projection='cyl'

However, the projection is 'lcc'.

When I change the projection part as 'merc' and others, it shows the same error.

Even though I tried in various ways, it failed.

If you know about this or have some hints for this, could you please let me know about the solution?

1 Answers1

0

I could not find the way to use drawmapscale, but found another way.

https://stackoverflow.com/a/35705477/19600737

This is the link I got help.