2

I am trying to update a feature class by joining it to a table after deleting columns in the target layer with the same names as columns in the join table. I thought the only way to do this in arcpy was to make the featureclass a feature layer and make the table a table view. I tried my script with out using featur layer or table view and got an error that the datatype was not a raster or mosiac. I then made the feaute layer and table view but now am getting error 000732 Dataset does not exist or is not supported.

Here is my script so far:

# script to update Signal dashboard

import arcpy
from arcpy import env

# set up env DB to overwrite outputs
env.workspace = r"C:\Users\Master\Documents\ArcGIS\Projects\Signal_Mgmt\Signal_Related_Apps.gdb"
env.overwriteOutput = True

# set up paths vars, etc
outPath = r"C:\Users\Master\Documents\ArcGIS\Projects\Signal_Mgmt\Signal_Related_Apps.gdb"

# the table used for updating featureclass
table = r"C:\Users\Master\OneDrive\Desktop\Temp out\EOC\Signal_MGMT_Census\AC_zips_rates.csv"

joinTable = arcpy.TableToTable_conversion(table, outPath, "AC_zips_rates")

# Current featureclass published to AGOL
inFC = r"C:\Users\Master\Documents\ArcGIS\Projects\Signal_Mgmt\Signal_Related_Apps.gdb\Zips"

# Get rid of fields from previous update
delFields = ["Count", "Jul_2020_Pop", "Rate_per_1000", "Popup", "Legend", "Bin"]

arcpy.management.DeleteField(inFC, delFields)

# make layer and table views to perform join ops
inField = arcpy.MakeFeatureLayer_management(inFC, "target_lyr")

joinView = arcpy.MakeTableView_management(joinTable, "join_view")

inTab = arcpy.JoinField_management(inField, "Zip_Number", joinView, "Zip")

# export joined tables as new FC
joinOut = arcpy.FeatureClassToFeatureClass_conversion(inTab, outPath, "Signal_Update")

# Remove join from current featureclass so join does not interfre with overwrite
arcpy.RemoveJoin_management(inField)

# Overwrite current featureclass with new featueclass
upFC = arcpy.FeatureClassToFeatureClass_conversion(joinOut, outPath, "Zips")

# delete join field from new featureclass
arcpy.management.DeleteField(upFC, "Zip")

# apply symbology layer to new featireclass
arcpy.ApplySymbologyFromLayer_management(upFC, r"C:\Users\Master\OneDrive\Desktop\Temp out\EOC\Signal_MGMT_Census\Signal_Zips.lyrx")

Am I going about this the wrong way? I can't seem to do a join op either way. I'm using ArcGIS Pro 2.5.

  • You could simplify the process if you used Join Field resources.arcgis.com/en/help/main/10.2/index.html#//… instead of join and export, Join Field is happy to work with a feature class and table instead of feature layer and table view. Which line is the error on? – Michael Stimson Apr 27 at 4:24
  • @MichaelStimson it's happening at line 34 joinOut. Aren't I already using join field? – geoJshaun Apr 27 at 4:55
  • Right you are, I only skimmed the code and saw you're making a layer and view and assumed you were using a table join. Join Field returns nothing which would be why you're getting an error, joinOut is nothing. The parameters should be (inFC,"Zip_Number",joinTable,"Zip") - remove the lines for Make Feature Layer and Make Table View, they're not needed. The fields from the joinTable are added to inFC and populated with the joined value... so be careful of locks, if the feature class can't be modified there will be errors. If you have further issues you could use an update cursor and a dict. – Michael Stimson Apr 27 at 5:05
1

You are creating result objects and then trying to use these as input to tools wanting tables, feature classes, feature layers, etc. as input.

With:

joinTable = arcpy.TableToTable_conversion("ak_riks", 'memory', "ak_riks_copy")

joinTable will not be the output table but a result object:

type(joinTable)
<class 'arcpy.arcobjects.arcobjects.Result'>

The output table is in my example 'memory\ak_riks_copy' and this is what you should input to MakeTableView.

Or:

joinTable.getOutput(0)
'memory\\ak_riks_copy'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.