Select to view content in your preferred language

ArcPy generate near table results differ (ObjectID) from results of using the tool in ArcPro…

664
3
11-09-2021 10:58 PM
DaveEibert
New Contributor

Hello,

I am trying to replicate a chain of commands in Python (Jupyter notebook) which is the same series of commands that run in ArcPro without issue. It appears the sticking point is the ArcPy tool “generate near table”. In ArcPro this tool assigns an ObjectID to the generated table so that additional operations can be performed on the table such as joining this data/attribute table to other attribute tables. In the script I am working on Jupyter/Python/ArcPy assign an ObjectID value of -1 for all attributes, which makes this table incompatible with other operations such as “Add Join” or “Join” as previously mentioned. Any Help would be greatly appreciated.

arcpy.analysis.GenerateNearTable(path+'shp/location.shp',path+'faults/Qfaults_GIS/SHP/Qfaults_US_Database.shp', path+'table/table.csv', '25000 Meters', closest = 'ALL', method="PLANAR")

arcpy.management.JoinField(path+'table/table.csv', 'NEAR_FID', path+'faults/Qfaults_GIS/SHP/Qfaults_US_Database.shp', 'FID')

Error message 000339 is the result citing that the .csv file does not have an object ID (which is either a value of -1 or absent depending on the output file type).

Thanks for looking!

Dave

0 Kudos
3 Replies
by Anonymous User
Not applicable

I think csv’s need to have objectids created by using the tabletotable method, even if there is a column ‘objectids’ in the csv. Try creating a temp table in memory for the near me and join operation? 

0 Kudos
DanPatterson
MVP Esteemed Contributor

Table To Table (Conversion)—ArcGIS Pro | Documentation see the python code tab

you can try memory but a gdb table works best, you can always add Delete after you are done with it


... sort of retired...
0 Kudos
DaveEibert
New Contributor

Thanks guys, exporting into a GDB seemed to do the trick!

0 Kudos