The code:
import os import arcpy def PointDistance (inFeat, nearFeat, outTable): #create table tabPath, tabName = os.path.split (outTable) arcpy.CreateTable_management (tabPath, tabName) #add fields fldDi = {"INPUT_FID" : "LONG", "NEAR_FID" : "LONG", "DISTANCE" : "DOUBLE"} for fld in ["INPUT_FID", "NEAR_FID", "DISTANCE"]: arcpy.AddField_management (outTable, fld, fldDi [fld]) with arcpy.da.InsertCursor (outTable, ["INPUT_FID", "NEAR_FID", "DISTANCE" ]) as iCurs: with arcpy.da.SearchCursor (inFeat, ["OID@", "SHAPE@" ]) as inCurs: with arcpy.da.SearchCursor (nearFeat, ["OID@", "SHAPE@"] ) as nearCurs: for inOid, inGeom in inCurs: for nearOid, nearGeom in nearCurs: row = (inOid, nearOid, inGeom.angleAndDistanceTo (nearGeom) [1]) iCurs.insertRow (row)
This comment has been removed by a blog administrator.
ReplyDeleteThanks for sharing for more Django Python Tutorial
ReplyDelete