Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import arcpy
- #inFeat is the path to your input feature class
- #nearFeat is the path to your near feature class
- #outTable is the path to the table that will be created by the function
- 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)
Add Comment
Please, Sign In to add comment