# -*- 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))
原文地址:https://www.cnblogs.com/gisoracle/p/11361173.html
时间: 2024-11-06 09:48:26