I have zero background in programming. I am trying to code something for my class and it is giving me an error "not enough values to unpack (expected 2, got 1)". What might be wrong with my codes?
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import shapefile as shp
#Read x, y, z file
data = pd.read_excel('RegionV.xlsx', header = None)
# Get X, Y, Z values from file
data = np.array(data)
data = data.astype(np.float)
x = data[:,0]
y = data[:,1]
z = data[:,2]
#Mask negative values of z (bathemetry)
zz = np.ma.masked_where(z <= 0, z)
#Create a map using basemap
fig = plt.figure(figsize=(10,10))
map = Basemap(projection='mill',llcrnrlat=11,urcrnrlat=15,\
llcrnrlon=122,urcrnrlon=125,resolution='h')
lon = np.linspace(min(x), max(x))
lat = np.linspace(min(y), max(y))
xs, ys = np.meshgrid(lon, lat)
x, y = map(xs, ys)
map.drawparallels(np.arange(12.,14.,0.5), labels=[0,0,0,1])
map.drawmeridians(np.arange(123.,126.,0.5), labels=[1,0,0,0])
#Plot
cmap = plt.cm.jet
cmap.set_bad(color='white')
m.pcolormesh(x, y, zz, cmap=cmap, vmax=1300, vmin=0)
m.colorbar(location='right', label='meters')
map.drawmapboundary()
map.drawcoastlines()
the first part of the error message says:
ValueError Traceback (most recent call last)
<ipython-input-50-3d7531011dc2> in <module>
44 cmap = plt.cm.jet
45 cmap.set_bad(color='white')
---> 46 m.pcolormesh(xs, ys, zz, cmap=cmap, vmax=1300, vmin=0)
47 m.colorbar(location='right', label='meters')
then, at the end,
ValueError: not enough values to unpack (expected 2, got 1)
Stackoverflow is not allowing me to post the entire error message. Hope everyone who see my post understands what I mean.