如何获取与IDL中某些坐标点的shapefile对应的像素数据?

时间:2013-12-11 13:03:27

标签: coordinates pixel idl-programming-language

我想得到的是与矢量文件中这些点对应的像素数据。并在8的窗口中将像素周围的最大值添加到坐标作为新值。我是IDL的新手,我该如何解决这些问题呢?提前谢谢!

2 个答案:

答案 0 :(得分:0)

我不太确定你所指的像素数据是什么,所以我假设它是另一个可以用shapefile坐标索引的数组。也许this article可以帮助你提取多边形的顶点(看起来你将不得不为他所用的例程咳出一点钱)。如果您希望获得每个像素周围的最大值,在获得每个xy向量以索引数据(下面的pixel)后,您将需要执行一些{{ 3}}。像下面这样的东西可能会起作用,但我没有测试过它(你可能不得不使用计算最大值的维度):

n = n_elements(x)
; pixel = findgen(np, np)

; Make a copy of "pixel" so we can eliminate the center element
; from consideration of the maximum
new_pixel = pixel
new_pixel[x, y] = new_pixel[x + 1, y + 1]

x = rebin(reform(x, n, 1), n, 9)
y = rebin(reform(y, n, 1), n, 9)

x += rebin(reform([-1, 0, 1], 1, 3), n, 9)
y += rebin(reform(rebin(reform([-1, 0, 1], 3, 1), 3, 3), 1, 9), n, 9)

; Get surrounding elements
new_pixel = new_pixel[x, y]
; Get maximum
max_pixel = max(new_pixel, dimension=2)

答案 1 :(得分:0)

我强烈建议在将矩阵索引导入IDL之前使用QGIS进行shapefile操作。然后你可以执行一个简单的计算:

output = input [where(index eq shp_value)]

要对齐像素,我会在QGIS中创建索引栅格时将shapefile值写入现有栅格。我相信你想要Rasterize工具。有关详细信息,请阅读有关区域统计信息的reply

干杯,

亚当