PDAL可以用来在一组多边形中找到最大点吗?

问题描述 投票:0回答:1

我正在寻找大量多边形中每一个的最高点。我正在使用这条管道:

[            
    'points.las',
    {'type': 'filters.crop', 'polygon': polygons},
    {
        "type": "filters.outlier",
        "method": "statistical"
    },
    {
        "type": "filters.range",
        "limits": "Classification![7:7]"  
    },
    {'type': 'filters.locate', "dimension": "Z", "minmax": 'max'},
    {"type": "writers.text", "precision": 8, "filename": 'output.csv'},
]

其中

polygons
是WKT中的一长串多边形。不幸的是,如果多边形不包含任何点,则不会向 CSV 输出任何内容,从而无法将高点与对应的多边形相关联。

我想知道是否有办法解决这个问题,或者告诉

filter.locate
如果没有积分就输出其他东西。

point-cloud-library pdal
1个回答
0
投票

这是实现它的一种方法,以防其他人遇到这个问题:

def locate_max(ins,outs):

    if ins['Z'].shape[0] == 0:
        for k in ins.keys():
            outs[k] = np.array([0], dtype=ins[k].dtype)
    else:
        i = np.argmax(ins['Z'])
        for k in ins.keys():
            outs[k] = np.array([ins[k][i]])
                
    return True

然后将这样的阶段添加到您的管道中:

{
    "type":"filters.python",
    "script":"pdal_functions.py",
    "function":"locate_max", 
    "module":"anything"
}
© www.soinside.com 2019 - 2024. All rights reserved.