0

我正在识别二维numpy数组中浮点值大于某个阈值的对象。然后我需要确定每个对象的长轴长度,并确保对象的长轴长度满足以公里为单位的某个阈值。

通过使用 scipy.ndimage.measurements.label 模块,我可以在二维 numpy 数组中识别我想要的对象。然后,我可以使用 scikit-image regionprops 模块 (skimage.measure.regionprops) 确定每个对象主轴的长度。

但是,我不确定对象长度的单位是什么,因为 2-D numpy 数组本身没有关于坐标的任何信息。二维 numpy 数组本质上是一个映射到地球表面子域的数据集。此外,我还有另外两个与我的数据数组大小相同的二维 numpy 数组,其中一个数组包含每个网格点的纬度坐标,另一个包含经度坐标。我相信我需要以某种方式使用 lat/lon 数组来确定我的对象的主轴的长度,但我不知道如何。

这是我到目前为止的代码:

from scipy import ndimage
from skimage.measure import regionprops
import numpy as np

# 2-D numpy array with data.
data

# 2-D numpy arrays with latitude and longitude coordinates that are same grid as data array.
lat
lon

# Allow label module to have diagonal object matching.
struct = np.ones((3,3), dtype=bool)

# Find objects in data array.
labl, n_features = ndimage.measurements.label(data>=35,structure=struct)

# Find major axis length in labl array for each object found.
props = regionprops(labl)
# Loop through each object.
for p in props:

    # Find object's major axis length.
    length = p.major_axis_length

    (some code to compute major axis length in kilometers?)

    if length < 125: #(125 is in km)
        (keep object)

任何帮助将不胜感激。谢谢!

4

0 回答 0