- The data: PL_Fac -point file - facilities used in service area analysis - contains PNTID in Add_PNTID field PD - polygon - catchment areas assigned to a facility (there can be many polygons assigned to one point. the polygon file contains a PNTID that corresponds to the PNTID of the facility. The PNTID is also in the feature name Civic - point file - civic addresses of people who live in the PD polygon areas. The PNTID is in the feature name
- The Purpose: I'm trying to determine if the civic point fall within the service areas they area assigned to. Thus far the civic points do not contain a PNTID but I may need to add one. The script below searches for similar names of the features.
- The Problem: I'm working with the below script to iterate through over 600 points. It finds PNTIDs that are similar if I fill in the ROW section with the PNTID however, I want the script to automatically grab the PNTID from the Add_PNTID field in the Facilities PL_Fac point file. After the search cursor finds features I then want to select the two found features (one PD_polygon and one Civic_point) and feed them into separate tools. Currently I can't get MakeFeatureLayer from the output from the search cursor. Not sure if some other method might work?
I'm using ArcGIS 10.2 Desktop
import arcpy, os, sys
### #UpdateCursor(dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields})
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"F:\PL_DriveTime\PL_DriveTime.gdb"
fcPNTID = r"F:\PL_DriveTime\PL_DriveTime.gdb\EG\PL_Facilities"
fcPNTID_lyr = "fcPNTID_lyr"
flds = ('Add_PNTID')
try:
with arcpy.da.SearchCursor(fcPNTID, flds) as cursor:
row = cursor.next()
print(row)
commonSearchText = ['ROW']
for nameX in commonSearchText:
foundFCList = []
walk = arcpy.da.Walk(arcpy.env.workspace, datatype="FeatureClass")
for dirpath, dirnames, filenames in walk:
for filename in filenames:
found = filename.find(nameX)
if found >-1:
foundFCList.append(os.path.join(filename))
print foundFCList
except StopIteration:
print("no rows")
except arcpy.ExecuteError:
print arcpy.GetMessages(2)
arcpy.AddError(arcpy.GetMessages(2))
except Exception as e:
print e.args[0]
arcpy.AddError(e.args[0])
row[0]
should return the value of the first field inflds
.row[1]
the second field etc (if you had a list of more fields)