Skip to content

Instantly share code, notes, and snippets.

@amarinelli
Created October 23, 2015 17:18
Show Gist options
  • Save amarinelli/daad2cec74f4ad2f64db to your computer and use it in GitHub Desktop.
Save amarinelli/daad2cec74f4ad2f64db to your computer and use it in GitHub Desktop.
Search Cursor (arcpy)
# from: http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/searchcursor-class.htm
import arcpy
fc = 'c:/data/base.gdb/well'
fields = ['WELL_ID', 'WELL_TYPE', 'SHAPE@XY']
# For each row print the WELL_ID and WELL_TYPE fields, and the
# the feature's x,y coordinates
with arcpy.da.SearchCursor(fc, fields) as cursor:
for row in cursor:
print('{0}, {1}, {2}'.format(row[0], row[1], row[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment