0

Using arcpy with slightly modified code from created by Felix Creating parallel line in ArcGIS Pro using ArcPy I made four parallel lines. I then used arcpy.AddXY_management to extract the vertices from the four lines. Up to here, all is good. My problem is controlling or modifying the sequence of which arcpy.AddXY_management assigns FID. Below is a simple version. enter image description here Here is a subset of the full version. Subset of the full version.

It is hard to depict and explain, but I want to be able to control which point is FID=0 and have sequence proceeded snake-wise. For example, start at the upper right point go down the line to the next point, move one point left, go up to the point across the line, move left to the next point down the line to the next point, and then left again ( lower left point) and then back up across the line. The goal is to create feature points with an FID order for like a lawnmower or a tractor.

  • 2
    You can't change the OID, but you could easily assign some other column -- see gis.stackexchange.com/questions/73978/… – Vince Mar 20 at 4:07
  • 1
    Expanding on what @Vince commented, FID is a pseudo field in the antiquated dBase 4 table structure, it is always 0 based, unique, contiguous and ascending, every time you save edits the FIDs compact to meet this rule so feature can have a different FID over its lifetime. The FID field doesn't really exist so it cannot be assigned to as it is completely managed by the database. ObjectIDs in contrast are managed by personal, file or enterprise databases and are 0 based, unique and ascending but are not guaranteed to be contiguous, this field is read-only and is managed by the database. – Michael Stimson Mar 20 at 4:31
1

FID values cannot be changed (at least not without some horrible hackery outside of ArcGIS/arcpy that you should not attempt). The only way to control the order of the FID is to create the features in order. The FIDs are created sequentially starting at 0.

Having said that, FIDs should not really be used for your own purposes. FIDs are designed for the system to use. You should be looking for another solution. Eg, create another attribute called, eg, 'SortID'. Populate this attribute with numbers that represent the sort order you want, and then sort on this attribute.

In order to provide any more information, I think you may need to explain what your base problem actually is. Ie, the problem that you wanted to solve by controlling FIDs. However, that may need to be done in other questions, as it would be quite a different question to this one.

  • 1
    Definitely! I've seen some real disasters born of FID as Key joins, when the FIDs change during an edit or two the features no longer point to the correct rows in the joined table. It would be much better to follow a method like gis.stackexchange.com/questions/95249/… – Michael Stimson Mar 20 at 5:46

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.