搜索此博客

2018年1月14日星期日

Create Random Points based on arcpy (批量生成随机点)

# -*- coding: utf-8 -*-
"""
Created on Sat Jan 13 20:49:27 2018

@author: Baikal
"""
# Import system modules
import arcpy, os
from arcpy import env


# First: To achieve dissolve the shapefile.

# Set local variables
inFeatures = r"G:\2016.06.MOD\MOD02\10Batch_2_Shp/"
list_file = os.listdir(inFeatures)
# Shapefile 
file_count = 0
for filename in list_file:
    if filename.endswith('.shp'): file_count = file_count + 1
print '共有',file_count,'个矢量文件产生随机点'
for filename in list_file:
    inFeaturesName =inFeatures + filename
    if filename.endswith('.shp'):
        outFeatureClass = r"G:\2016.06.MOD\MOD02\10SHP_Dissolve/" + filename
        outFeatureName = filename
        dissolveFields = ["DN"]
        # Execute Dissolve using LANDUSE and TAXCODE as Dissolve Fields
        arcpy.Dissolve_management(inFeaturesName, outFeatureClass, dissolveFields, "", 
                      "MULTI_PART")
        
        # Second: To create several types of random points feature classes
        
        #set environment settings
        #env.overWriteOutput = True
        # Create random points in an extent defined simply by numbers
        out_path = r"G:\2016.06.MOD\MOD02\11Validation\test/"
        outName = filename
        fcExtent = outFeatureClass
        numPoints = 200
        numField = "DN"
        minDistance = 6000
        arcpy.CreateRandomPoints_management(out_path, outName, fcExtent, "" , numPoints, minDistance)

没有评论:

发表评论

LibSVM Chinese Brief Infroduction

Reference: [1]  https://blog.csdn.net/v_july_v/article/details/7624837 [2]  https://wenku.baidu.com/view/c402e983336c1eb91b375d37.html?fr...

  • Word (2)