这几天抽空写了一些arcgis python入门类的脚本,详细信息注解以后加入.首先是获取数据信息类的应用.
获取信息函数直接copy的.看起来有点繁琐.先不改了.嗯嗯=.=
import arcgisscripting #### get field's info function def PrintFiledsInfo(fc): des = gp.Describe(fc) fields = des.Fields fields.reset() field = fields.next() while field: print "|fieldname: |" + field.Name + " |" + "fieldtype: |" + field.Type +" |" print "--------------------------------------------" field = fields.next() #### print feature's Area function def PrintArea(fc): rows = gp.searchcursor(fc) rows.reset() row = rows.next() while row: geom = row.GetValue("Shape") print geom.Type print "area: " + float.__str__( geom.Area) row = rows.next() ###print feature's length function def PrintLength(fc): rows = gp.searchcursor(fc) rows.reset() row = rows.next() i = 0 while row and i < 10: geom = row.GetValue("Shape") print geom.Type print "line: " + float.__str__( geom.length) i = i + 1 row = rows.next() ## print point x&y def PrintPoint(fc): rows = gp.searchcursor(fc) rows.reset() row = rows.next() i = 0 while row and i < 10: geom = row.GetValue("Shape") print geom.Type print "point: " + geom.firstpoint i = i + 1 row = rows.next() #######main func if __name__ == "__main__": gp = arcgisscripting.create() gp.Workspace = r"C:\ArcGIS\DeveloperKit\SamplesNET\data\SanFranciscoNetwork" fcs = gp.ListFeatureClasses() fcs.reset() fc = fcs.next() while fc: print "**************" print "* " + fc + " " print "**************" PrintFiledsInfo(fc) des = gp.Describe(fc) if des.shapetype == "Polygon": PrintArea(fc) if des.shapetype == "Polyline": PrintLength(fc) if des.shapetype == "Point": PrintPoint(fc) fc = fcs.next()
arcpy是一个新的python包吗?那跟以前的写法会不会变化很大?
新的包.支持800+geoprocessing工具和全部的地圖代數的分析工具.
寫法變化不大.
循環遍歷更方便了.
改天寫點上來.