How do I can update the object id to a shapefile

5403
7
06-23-2016 06:39 AM
PrasadsinhDalavi
New Contributor II

I converted XY values to the points, however when I tried to generate the Object-ID to the same shapefile using Add field tool, the tool didn't work, popping out with a message that table is not editable. can anybody help me to come out of this problem?

0 Kudos
7 Replies
DanPatterson_Retired
MVP Emeritus

The FID field can't be edited or modified.  If you want to add a new field, you can add one as and integer field, then simply calculate values for it using the field calculator (ie newfield = FID or similar)

PrasadsinhDalavi
New Contributor II

Sir I want to generate FID to shapefile automatically while plotting it from .csv. FID can be generated as per your answer and also once we plot it from table and export it then automatically FID will be generated. I want to generate it while plotting.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Can you elaborate on "while plotting it from .csv."

If you are plotting x,y coordinates from a CSV file, have you looked at Make XY Event Layer?  The Make XY Event Layer tool won't generate an FID/OID, but it does convert your x,y coordinates into a valid layer in ArcMap.

Why do you need an FID/OID dynamically created?  What are you trying to do that is prevented from not having that field?

PrasadsinhDalavi
New Contributor II

You are close to clarify my  doubt, I know that we can use Make XY Even Layer to plot our coordinates from csv/xlxs files, but what I want is FID/OID must be created dynamically while plotting the coordinates.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I am still interested in why you need to have an FID/OID field with your event layer(s)?  What are you trying to do with your event layer(s) that can't be done without an FID/OID field present?

You mention "csv/xlxs files."  I would argue that CSV and XLS/XLSX files are different enough, and thus handled differently enough by ArcGIS Desktop, that what works for one might not work for the other.

I am not recommending the following, but there is an option for CSV/text files using the Make Query Table tool.  The Make Query Table tool supports OLE DB connections, which means you can work with CSV/text files if your machine's data drivers/sources are setup correctly.  The reason I mention the Make Query Table tool is that it can dynamically create an OID field.

General steps:

  1. Setup machine's data drivers/sources to handle CSV/text files through OLE DB.
  2. Run the Make Query Table tool and specify Key Field Option of "ADD_VIRTUAL_KEY_FIELD".
  3. Take the generated table and enable XY display of data:
    arcmap_layer_display_xy_data.PNG
  4. Work with new Events layer
    arcmap_layer_xy_events.PNG

I believe the query table can be removed afterwards and the event layer is still valid.  I haven't tried scripting the steps above, but it seems like it should be possible.  The biggest hassle, by far, will be managing the OLE DB connections to lots of CSV/text files.

PrasadsinhDalavi
New Contributor II

Joshua I know this method. I'm just trying to explore the other way but couldn't get the answer. thanks for you prompt reply.

0 Kudos
DanPatterson_Retired
MVP Emeritus

As Joshua says, make your event layer, then save it out to a shapefile and the FID will be created, or make it in a geodatabase and you will get the same thing but it is called OBJECTID.  If the problem is that you want stuff in a different order than would be generated... do the reordering before bringing it.  Once, created the FID remains as long as the feature exists.  IDs only get regenerated when edits are done and saved.