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

1303
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
1 Solution

Accepted Solutions
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. 

View solution in original post

0 Kudos
15 Replies
Robert_LeClair
Esri Notable Contributor

Since the Python script worked using ArcGIS Pro 2.6.x and does not work in ArcGIS Pro 2.9.2, it has me wondering if something in Python changed between the two releases.  You could run the Analyze Tools for Pro to determine if the Python script functionality is correct.  What is the result?

0 Kudos
KathleenMohla1
New Contributor II

Ran the Analyze Tools for Pro and No Problems reported.

0 Kudos
Robert_LeClair
Esri Notable Contributor

Thx for the update Kathleen - I saw a response that describes this error message and mentioned something about an in_memory issue in a script.  You can read about it here.

0 Kudos
KathleenMohla1
New Contributor II

Thank you Robert. I'll check it out.

0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor

Hi Kathleen,

Does the tool work from tool dialog? Could you share a repro sample of the script and data? I can pass it to my team (Geoprocessing).

Thanks,

Dan

0 Kudos
KathleenMohla1
New Contributor II

Hi Dan,

The script is within a toolbox and when run displays like other geoprocessing tools within the application interface - I think that is what you are asking.

I've attached a geodatabase with the input feature class (AR_clip) and the script (Check Secondaries Match Primaries) within the ValidateTools toolbox.

Thank you for the assistance. Hope your team can shed some light on what the hang up is.

Kathleen

0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor

I got the gdb, but not the ValidateTools toolbox with the script tool and source code. Could you share those?

0 Kudos
KathleenMohla1
New Contributor II

The toolbox should be in the gdb and the script within the toolbox.

KathleenMohla1_0-1654643799819.png

Let me know if it's not there and I'll try and send it again.

0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor

I see the toolbox and the script tool, but when I tried to run with your input AR_clip, it says no associated script:

DanLee_0-1654646670126.png

Could you share the py file? I can connect it to the tool by myself.

0 Kudos