利用arcpy按字段值筛选要素工具

ArcGIS按字段值筛选要素做缓冲区分析时要先进行字段筛选然后再进行缓冲区分析。而不能直接在缓冲区工具中直接筛选,于是乎就有了本工具的编写。

工具中一共有7个参数:

一.输入要素 (shapeFilel类型)

二.SQL筛选语句(SQL语句)

三.输出要素(shapeFile类型input)

四.缓冲半径(字符串)

五,侧类型(字符串)

六.末端类型(字符串)

七.融合类型(字符串)利用arcpy按字段值筛选要素工具_第1张图片

代码如下:

__author__ = 'Administrator'
import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True
catch = "cache"
inputShpFile = arcpy.GetParameterAsText(0)
selectSQL = arcpy.GetParameterAsText(1)
selectSQL2 =  selectSQL
outputShpFile = arcpy.GetParameterAsText(2)
arcpy.MakeFeatureLayer_management(inputShpFile,"cities_lyr")
arcpy.SelectLayerByAttribute_management("cities_lyr", "NEW_SELECTION",selectSQL2)
arcpy.CopyFeatures_management("cities_lyr", catch)
distance = arcpy.GetParameterAsText(3)
sideType = arcpy.GetParameterAsText(4)
endType = arcpy.GetParameterAsText(5)
dissolveType = arcpy.GetParameterAsText(6)

arcpy.Buffer_analysis(catch, outputShpFile, distance, sideType, endType, dissolveType)

你可能感兴趣的:(ArcGIS,arcgis,arcpy,class,sql)