0

I know how to plot contours on basemap using netcdf files. However, I have a bunch of points corresponding with a correlation value saved in a text file that I would like to plot their contours on a basemap.

Here are the data (first lines):

lons    lats    correl 
262.203 82.0331 nan
262.79  82.0338 0.084949063
263.368 82.0338 0.091800957
263.955 82.033  0.095236276

and here is my code so far:

lons, lats, cor=np.loadtxt(correl_map, unpack=True, skiprows=1)
plt.figure(figsize=(10,10))
plt.subplot()
m = Basemap(width=1200000, height=900000,resolution='h'\
,projection='npaeqd', boundinglat=70, lon_0=0)
m.drawcoastlines()
x,y = m(lons, lats)
cs=map.contour(x,y, cor)
plt.show()

I tried different ways of plotting contours, and for each I get many different errors. For the simplest code above, I am getting this error:

Traceback (most recent call last): File "plot.py", line 25, in lons, lats, correl=np.loadtxt(correl_map, unpack=True, skiprows=1) ValueError: too many values to unpack

I would appreciate any help.

Behnam
  • 501
  • 1
  • 5
  • 21
  • Clearly, the problem is with your first line of code. – swatchai May 29 '18 at 02:04
  • @swatchai I would appreciate also your solution for that! – Behnam May 29 '18 at 12:18
  • My answer to another question: https://stackoverflow.com/questions/50545802/how-to-plot-interpolate-station-data-over-a-map-basemap/50550805#50550805 is useful for you. Please take a look. – swatchai May 30 '18 at 12:11
  • Are your columns delimited by whitespaces or tabs? What do you get if you do `res = np.loadtxt(correl_map, unpack=True, skiprows=1)` give you, i.e. what does `res` look like in this case? Also, have a look at [this](https://stackoverflow.com/q/10686657/2454357). – Thomas Kühn May 30 '18 at 12:44

0 Answers0