I'm currently using a Virtual Feature class, adding a field from a spatial
join, then exporting the result to Excel.
I'm deleting the virtual fc and join, by running
arcpy.management.RemoveJoin(virtual_FC,countryFC)
and
arcpy.Delete_management(virtual_FC)
..but despite me closing everything down, this - keeps happening.
I need to run four different 'join' and 'calculate' operations in my script, so this is really throwing a spanner in the works.
I am turning ArcGIS Pro and PyCharm off and on - so I've got no idea where this
information about the previous runs is being stored.
Hi @Anthony_R_McKay,
Any luck fixing this issue? I am in the middle of something similar. Any help is appreciated.
Thanks.
Hi! I haven't found a way to fix the root issue (join names changing number every time), but I have a workaround for the calculate issue specifically!
Rather than entering the full "VF_Jason_King_Locations_AddSpatialJoin_13.COUNTRY", what worked for me was shortening this to just the part after the period. In this case, it would be just "COUNTRY".
In my case, what I originally had was the following:
arcpy.management.CalculateField(
in_table="GeoTaggedPhotosToPoints",
field="PhotosWatershed",
expression="!GeoTaggedPhotosToPoints_AddSpatialJoin.Watershed!"
expression_type="PYTHON3"
)
Predictably, this only worked for the very first spatial join because of the name change issue. What ended up working for every subsequent join, regardless of the irritating naming convention, was the following:
arcpy.management.CalculateField(
in_table="GeoTaggedPhotosToPoints",
field="PhotosWatershed",
expression="!Watershed!"
expression_type="PYTHON3"
)
I hope this helps at least one person with the same issue!
*Edit: I haven't tried this one yet, but another possible solution may be a permanent join. good luck!