Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a feature class and I need to know the ObjectID of its last record.

What is the best way to find out last ObjectID?

Opening a search cursor and reading all the records is one way, but is there any other way?

share|improve this question
In a shapefile or database feature class? – Michael Miles-Stimson Aug 22 '14 at 2:57
In Database feature class , data set is in versioned SDE database – shafey Aug 22 '14 at 3:59
Refer the answer by PolyGeo. Shapefiles are special in that their FIDs compress after editing so (outside of edits) their FIDs are unique/ascending with no gaps. Database feature classes retain the same OBJECTID for the feature and do not reuse expired values so they, although unique, can have gaps. – Michael Miles-Stimson Aug 22 '14 at 4:02
Would you elaborate why do you need an ObjectID in first place? This is a system field which is maintained by ArcGIS and in general you don't want to build any business logic on this field. And by "last record", do you refer to the last edited/created feature? – Alex Tereshenkov Aug 22 '14 at 5:44
Actually , I have a feature class , that have no primary key to identify the individual records , I have a tool that inserted records onto feature class , before I insert I need to know what is the last record objectid – shafey Sep 5 '14 at 1:54

To do this I would use the Summary Statistics (Analysis) tool and this statistic type on ObjectID:

MAX—Finds the largest value for all records of the specified field.

Then if you want to read the MAX (highest) value you can use a search cursor on its output table to open and read the one record therein.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.