【发布时间】:2017-12-04 00:30:54
【问题描述】:
我有地理参考图像,其坐标值如 (475224.0, 4186282.0)。我的图像尺寸为 (647, 2180)。即有 647 列和 2180 行。我想将坐标值放入一个大小为 (647, 2180) 的 numpy 数组中,以便将每个像素的坐标作为一个数组获取。我的代码如下。
rr = rasterio.open(fname) #fname is the georefered image
col = rr.width
row = rr.height
coord = np.empty(shape=(col,row),dtype=rr.dtypes[0])
for i in range(0,col):
for j in range(0,row):
coord[i,j] = rr.transform*(i,j)
问题是 rr.transform*(i,j) 会给出类似 (475224.0, 4186282.0) 的值。如何将其保存到单元格中。对于上述程序,我收到如下错误
Traceback(最近一次调用最后一次):文件 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/interactiveshell.py", 第 2881 行,在 run_code exec(code_obj, self.user_global_ns, self.user_ns) 文件“”,第 3 行,在 coord[i,j] = rr.transform*(i,j) ValueError: setting an array element with a sequence.
【问题讨论】:
-
“逗号分隔值”是什么意思?是
tuple吗?
标签: python arrays numpy multidimensional-array rasterio