In a given city a line is constructed, and for every building in that city it is required to know the distance to that line. Therefore the .distanceTo method from the ArcPy Geometry class is used. It is also required that this distance is multiplied by 1.2.
The following code is written using ArcPy (10.4):
from arcpy import * # A new attribute is first created to populate the distances with AddField_management('buildings', 'distanceField', 'LONG') buildingCursor = UpdateCursor('buildings', '#', '#', ['SHAPE@']) lineCursor = SearchCursor('line', '#', '#', ['SHAPE@']) for building in buildingCursor: buildingGeometry = buildingCursor[0] lineGeometry = lineCursor[0] distance = buildingGeometry.distanceTo(lineGeometry) * 1.2 building.setValue('distanceField', distance) buildingCursor.updateRow(building) del buildingCursor, lineCursor, building The code returns an error. The error message is:
AttributeError: Object: Error in parsing arguments for UpdateCursor
How can I make this code work as intended?