1

I am working on a historical code base and it has a filter query that includes this condition:
[OBJECTID] >-1

The context surrounding the query doesn't explain why it would want to filter out negative IDs.

What are the circumstances under which an feature this field will hold a negative value?

  • 1
    There isn't any valid code that would populate a negative objectid. Any layer with negative registered rowid column would experience undefined behavior. I doubt it's even possible for most data formats that would have an objectid. – Vince Aug 13 '17 at 17:09
  • 1
    Perhaps author didn't know how to select all – FelixIP Aug 13 '17 at 21:05
  • Can you include more of the code for context? Object IDs are managed by the database the feature (row) that is storing it and should never be negative (as Vince said), I have a feeling that FelixIP is correct and it's a method to select all, which can be achieved by omitting the where_clause parameter from cursor/layer operations. But overlay/near operations are different, where the target FID is -1 the tool is saying 'no matching feature exists' which is a handy way to find isolated points and non-overlapping features depending on which tool is used. – Michael Stimson Aug 13 '17 at 21:29
0

As FelixIP stated, this may be an unusual method to select all records.

However, the OBJECTID field does not have to be an @OID field (rowid or fid). It can just be an integer field or text field. Any field could theoretically be titled 'OBJECTID'.

Some tools in ArcGIS, such as the union tool, will output -1 for the fid of features. For example, if you have feature class 'A' and feature class 'B' and you run the union tool on the two feature classes, the area in the union output where A exists and B does not will would have A.fid = 57(or whatever number >=0) and B.fid = -1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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