Wednesday, 14 December 2016

arcgis 10.2 - Selecting specific row in attribute table using ArcPy (without iterating through whole table)?



I am using ArcGIS 10.2 and have assumed until now that it is possible to select a specific row in an attribute table. However, I can't seem to find a way to do this. The only available methods seem to be to return a search or update cursor, and to iterate through each row in the table.


Is there really no way to select only the desired row?


What I am trying to do is to select a target row - e.g. 50423 - and then to update a field for that row. I'd hate to iterate through the entire table of millions of records.



Answer



In arcpy, When you implement the Search Cursor or Update Cursor you have the option of using the where_clause parameter, which will allow you to select a specific row based on a field value (e.g. row ID).


This help file will show you how to build an appropriate SQL query for selecting a specific row.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...