I have the following working script - here is an exerpt
rowCursor = arcpy.UpdateCursor(inputFC)
for row in rowCursor:
geom = row.getValue(desc.shapeFieldName)
from_point = geom.centroid
near_pts = 0
for to_point in coord_pairs:
distance = math.sqrt(pow((to_point.X - from_point.X), 2) + pow((to_point.Y - from_point.Y), 2))
if distance <= inputdistance:
near_pts += 1
row.cnt = near_pts - 1 # Subtract 1 to remove the measurement to itself
rowCursor.updateRow(row)
del rowCursor
I want to add it as a toolbox script in arcmap instead of running it from the python window. I've tried to rewrite it but I keep getting an error, so its wrong somehow. I have the getparameter as text part at the start, and it keeps erroring in this part. I think its where I have placed the setValue - but I have tried to adjust it and it keeps erroring.
rowCursor = arcpy.UpdateCursor(inputFC)
for row in rowCursor:
geom = row.getValue(desc.shapeFieldName)
from_point = geom.centroid
near_pts = 0
for to_point in coord_pairs:
row.getValue = math.sqrt(pow((to_point.X - from_point.X), 2) + pow((to_point.Y - from_point.Y), 2))
if distance <= inputdistance:
near_pts += 1
near_pts - 1
row.setValue("Cnt")
del rowCursor