python - Basemap Heat error / empty map -


i trying plot scattered heat map on defined geo location. can plot normal scattered map no background want combine given lat , lon. following empty mapenter image description here.

input

input: col[2] , col[3] x , y co ordinates & geo location lat:19.997453, lon:73.789802

000000000023 61.0 19.006113 73.009168  000000000054 65.0 19.009249 73.000342  000000000003 19.0 19.001051 73.000080  000000000012 20.0 19.009390 73.008638  000000000061 82.0 19.008550 73.003605  000000000048 86.0 19.006597 73.001057  00000000005d 60.0 19.003857 73.009618  000000000006 60.0 19.003370 73.009112  000000000037 91.0 19.002558 73.000546  000000000047 32.0 19.006061 73.008239  

program

from matplotlib import pyplot plt  matplotlib import cm cm matplotlib import mlab ml mpl_toolkits.basemap import basemap import numpy np   m = basemap(width=12000000, height=9000000, projection='lcc',              resolution='c', lat_0=19.,lon_0=73.) m.drawcoastlines(linewidth=0.25)  data = np.loadtxt('random_lat_lon_0', unpack=true,                    dtype='str, float, float, float')  x  = data[2] y  = data[3] z  = data[1]  gridsize = 100  m.hexbin(x, y, c=z, gridsize=gridsize)  cb = m.colorbar() #m.set_label('density') plt.show()   

no error see empty map no scatter plot of data on that.

how fix ? !!

i understand. trying combine answers received here-imshow , here-hexbin.

your problem boils down fact want use basemap "canvas" on plot 2d histogram. instead of doing that, making basemap plotting 2d histogram separately (using plt.hexbin makes separate canvas basemap).

use m.hexbin , rid of plt.imshow(). if want use imshow, need make separately 2d histogram array first, plot imshow. below how proceed hexbin.


edit: below randomized x, y, z data make plot (and made coastlines bigger). it's not perfect, shows data plotted.

from matplotlib import pyplot plt  matplotlib import cm cm matplotlib import mlab ml mpl_toolkits.basemap import basemap import numpy np   m = basemap(width=12000000, height=9000000, projection='lcc',              resolution='c', lat_0=19.,lon_0=73.) m.drawcoastlines(linewidth=0.25) # added color='red', lw=2.0  #data = np.loadtxt('inputfile', unpack=true,                    dtype='str, int, int, int, int, float') # #x  = data[1] #y  = data[2] #z  = data[5] x, y, z = np.random.rand(3, 1000000) x *= 12e6 y *= 9e6 z *= 20000  gridsize = 100  m.hexbin(x, y, c=z, gridsize=gridsize, cmap=plt.cm.ylgnbu)  cb = m.colorbar() m.set_label('density') plt.show() 

enter image description here


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -