python 基于OBJECTIDstart从要素类创建随机样本!

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 基于OBJECTIDstart从要素类创建随机样本!相关的知识,希望对你有一定的参考价值。

import arcpy
import numpy as np

def randomFCSample(fc, fd='sample_fd', sample_field='OBJECTID', sample_pct=10):
    count_class = arcpy.GetCount_management(fc)
    count = int(count_class[0])
    random_vals = np.random.choice(count, int(count*(sample_pct/100)))
    arcpy.MakeFeatureLayer_management(fc,
                                      fd + "_" + str(sample_pct) + 'pct',
                                      sample_field + ' IN ' + str(tuple(random_vals)))

以上是关于python 基于OBJECTIDstart从要素类创建随机样本!的主要内容,如果未能解决你的问题,请参考以下文章