Guest User

Untitled

a guest
May 17th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import os
  2. import arcpy
  3.  
  4. #inFeat is the path to your input feature class
  5. #nearFeat is the path to your near feature class
  6. #outTable is the path to the table that will be created by the function
  7. def PointDistance (inFeat, nearFeat, outTable):
  8. #create table
  9. tabPath, tabName = os.path.split (outTable)
  10. arcpy.CreateTable_management (tabPath, tabName)
  11. #add fields
  12. fldDi = {"INPUT_FID" : "LONG",
  13. "NEAR_FID" : "LONG",
  14. "DISTANCE" : "DOUBLE"}
  15. for fld in ["INPUT_FID", "NEAR_FID", "DISTANCE"]:
  16. arcpy.AddField_management (outTable, fld, fldDi [fld])
  17. with arcpy.da.InsertCursor (outTable, ["INPUT_FID",
  18. "NEAR_FID",
  19. "DISTANCE"
  20. ]) as iCurs:
  21. with arcpy.da.SearchCursor (inFeat,
  22. ["OID@",
  23. "SHAPE@"
  24. ]) as inCurs:
  25. with arcpy.da.SearchCursor (nearFeat,
  26. ["OID@",
  27. "SHAPE@"]
  28. ) as nearCurs:
  29. for inOid, inGeom in inCurs:
  30. for nearOid, nearGeom in nearCurs:
  31. row = (inOid, nearOid,
  32. inGeom.angleAndDistanceTo (nearGeom) [1])
  33. iCurs.insertRow (row)
Add Comment
Please, Sign In to add comment