POST
|
import arcpy
arcpy.MakeFeatureLayer_management('water_main_copy', 'water_main_copy_lyr')
arcpy.SelectLayerByLocation_management('water_main_copy_lyr', "WITHIN", 'water_main_buffer')
arcpy.SelectLayerByLocation_management('water_main_copy', "", "", "", "SWITCH_SELECTION")
arcpy.SelectLayerByLocation_management('mapnum_copy', "INTERSECT", 'water_main_copy')
fc = 'mapnum_copy'
field = 'MapNum'
cursor = arcpy.SearchCursor(fc)
for row in cursor:
print(row.getValue(field))
This would be a way to make a feature layer. Give it a try and if it gives you errors just follow the similar naming convention for feature layers for water_main_buffer and mapnum_copy. The text that comes will be the Map Numbers with unbuffered water mains. Hope this helps!
... View more
01-08-2020
01:40 PM
|
0
|
0
|
926
|
POST
|
Yes, it would. You may have to do it for each layer you are gonna do.
... View more
01-08-2020
01:24 PM
|
0
|
0
|
324
|
POST
|
What's the field name used in mapnum_copy for labelling?
... View more
01-08-2020
08:54 AM
|
0
|
2
|
926
|
POST
|
Can you tell it's my first time posting code to Geonet haha. Thank you for highlighting this to me.
... View more
01-08-2020
08:52 AM
|
0
|
0
|
324
|
POST
|
What's the name of the labeling field in mapnum_copy?
... View more
01-08-2020
08:46 AM
|
0
|
5
|
926
|
POST
|
Hi, I use a similar script from the Python window in ArcMap ##running from Python window in ArcMap with layers already MXD and using layer names as per your post import arcpy arcpy.SelectLayerByLocation_management('layer1', "WITHIN", 'layer2') arcpy.SelectLayerByLocation_management('layer1', "", "", "", "SWITCH_SELECTION") arcpy.SelectLayerByLocation_management('layer3', "INTERSECT", 'layer1') fc = 'layer3' field = 'layer3_field_that_contains_grid_name' cursor = arcpy.SearchCursor(fc) for row in cursor: print(row.getValue(field))
... View more
01-08-2020
08:45 AM
|
0
|
0
|
926
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|