首页 > 编程语言 > 详细

arcgis python 随机取部分数据

时间:2019-08-16 00:41:21      阅读:172      评论:0      收藏:0      [点我收藏+]
# -*- coding: cp936 -*-
import arcpy
import os
import ylpy
import random
def main():
    num=ylpy.getCount(inFeature)
    n=int(num*mscale/100)
    ylpy.clearselect(inFeature)
    A=random.sample(range(num),n)
    FID=ylpy.getOIDField(inFeature)
    sql=str(FID)+" in ("
    for i in range(0,n):
        sql=sql+str(A[i])
        if i<n-1:
            sql=sql+","
    sql=sql+")"
    arcpy.Select_analysis(inFeature,outFeature,sql)


inFeature = arcpy.GetParameterAsText(0) #
mscale = arcpy.GetParameter(1) #
outFeature = arcpy.GetParameterAsText(2) #


try:
    main()
    #arcpy.SetParameterAsText(3, inFeature)  # Is polygon
except Exception, ErrorDesc:
    arcpy.AddError(u"gisoracle错误:"+str(ErrorDesc))

 

arcgis python 随机取部分数据

原文:https://www.cnblogs.com/gisoracle/p/11361173.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!