在Python中生成热图时出现错误:ValueReror:必须通过2D输入。 shape =()
在Python中生成H3矩的地图时,我会遇到错误,以获取名为“ Image_test”的图像文件。错误显然是针对我为H3获得的值的形状。我的目标是仅在代码中从H3 [YCELL] [XCELL]中获得的H3值,然后使用该值在XY网格中创建一个红蓝色热图。我的驱动器中指向我的代码(image_stats.ipynb)的链接在下面。该代码使用文件“ image_test”,需要下载才能运行代码。 https://drive.google.com/drive/folders/1gxwsuxsohhanv5qv5qv-c1f-c1f4keuwelkmmrs?usp =
the主要问题可能是在代码的这段段落中
for ycell in range(8):
for xcell in range(13):
#cells[ycell][xcell] = np.array(vz_new[(y_new == ycell) & (x_new == xcell)],dtype=object)
cells[ycell][xcell] = vz_new[(y_new == ycell) & (x_new == xcell)]
#[ i for i in cells[ycell][xcell] if (math.inf not in i) and (math.nan not in i) ]
h3[ycell][xcell] = get_h3(cells[ycell][xcell])
#print(cells[ycell][xcell])
#print(h3[ycell][xcell])
#print('SHAPE IS=', h3[ycell][xcell].shape)
fig, ax = plt.subplots()
# heatmap
ax=sns.heatmap(h3[ycell][xcell], cmap='RdBu')
ax.invert_yaxis()
plt.show()
sharing sharing 用于完整代码。感谢您的帮助!如果需要,请要求澄清。
I am getting errors while generating maps of h3 moments in python for an image file called "image_test". The error apparently is for the shape of the values that I am getting for h3. My goal is to just take the h3 values that I get from h3[ycell][xcell] in my code and then use the values to create a red-blue heatmap in the x-y grid. The link to my code (image_stats.ipynb) in my drive is below. The code uses a file "image_test" which needs to be downloaded for code to run.
https://drive.google.com/drive/folders/1gXWSuxsOHHaNV5Qv-C1f4kEUwElKMmRS?usp=sharing
The main issue might be in this snippet of the code:
for ycell in range(8):
for xcell in range(13):
#cells[ycell][xcell] = np.array(vz_new[(y_new == ycell) & (x_new == xcell)],dtype=object)
cells[ycell][xcell] = vz_new[(y_new == ycell) & (x_new == xcell)]
#[ i for i in cells[ycell][xcell] if (math.inf not in i) and (math.nan not in i) ]
h3[ycell][xcell] = get_h3(cells[ycell][xcell])
#print(cells[ycell][xcell])
#print(h3[ycell][xcell])
#print('SHAPE IS=', h3[ycell][xcell].shape)
fig, ax = plt.subplots()
# heatmap
ax=sns.heatmap(h3[ycell][xcell], cmap='RdBu')
ax.invert_yaxis()
plt.show()
Not posting full code or error here because too long, so please check google drive link for full code. Thanks for any help! Please ask for clarification if needed.
NOTE: h3 is like a list of lists. looks like the following when printed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论