Generate Near Table fails to create a NEAR_FID field when running Python script in ArcGIS Pro 2.9.2

1321
15
Jump to solution
06-07-2022 11:24 AM
KathleenMohla1
New Contributor II

I've previously successfully run a Python script in ArcGIS Pro 2.6.x that included the use of the analysis geoprocessing tool, Generate Near Table. Recently upgraded to ArcGIS Pro 2.9.2 and attempted to run the same script and I get this error: ERROR 000728: Field NEAR_FID does not exist within table.

According to esri documentation the output table should have this field.

Anyone else experiencing the same thing?

0 Kudos
15 Replies
KathleenMohla1
New Contributor II

Of course... thank you, Dan.

Kathleen

0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor

We are having trouble adding your data to a map in a new project or processing your data using a full path. The gdb you shared may be corrupted.  Could you make a new gdb and copy your data over to the new gdb; you can use Copy Features to do that if you like. Please make sure you can add the data to a map, and then share that gdb (no toolbox inside it please)?

0 Kudos
KathleenMohla1
New Contributor II

Created a new gdb. Copied the feature using Copy Features and added to map. No toolbox inside the new gdb.

0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor

Thanks Kathleen. The new gdb worked. I can reproduce the error. I will update you when we know the cause.

0 Kudos
DrewFlater
Esri Regular Contributor

@KathleenMohla1  I work with Dan on the geoprocessing team, and we have been looking at your case. 

While we are investigating I want to point out that your code can be updated on line 91 from this:

arcpy.AddJoin_management(tbl_Near,"NEAR_FID", r"in_memory\xPriRtes", "OBJECTID")

 

to this:

arcpy.AddJoin_management(tbl_Near,"xNear.NEAR_FID", r"in_memory\xPriRtes", "OBJECTID")

 

and the script tool can complete successfully. (the difference is the xNear.NEAR_FID part in the second parameter). When you perform a join, the field names become qualified with the table name. It is best practice when using joined layers as input to include the table name qualification with the field name so that the processing tool knows the exact field to use. With what you have reported we are finding that there is some inconsistent behaviors when you exclude the table name qualification. I think this topic should be familiar to you already, as the script already includes usage of table name qualification when using join layers as input  (for example, the SelectLayerByAttribute and CalculateField tools on lines 92-93).

We will keep investigating to fix the issue so that the code can work as-is from 2.6 to a future release, but please take the table name qualification as a way to get up and running again. 

0 Kudos
KathleenMohla1
New Contributor II

I'll take the suggestion and include the table name qualification.

Thank you for providing the detailed response. 

0 Kudos