I have a feature class that has several sql db tables joined to it. It's been my workflow to update values in these tables, and then export the joined feature class over to sde GDB to use for published map services. I'm trying to automate this step using python. Is there a way in Python to open a map document (with the feature class and joined tables), select the feature class and export the feature class to a Geodatabase? Any help would be much appreciated.
Thank you
Hi Ryan,
I'm not positive about the join, but you can open a mxd with python using the arcpy.mapping module. It has access to the table of contents, so I would imagine the join would be active while open in python.
-Sam
Not an answer, but I believe this should have worked. It doesn't. It blanks out all the joined fields in the first layer, which has a join:
import arcpy arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument('C:/junk/junk_map.mxd') layers = arcpy.mapping.ListLayers(mxd) arcpy.CopyFeatures_management(layers[0],'C:/junk/FILE_GDB.gdb/copy')
Good to know. Thanks for the reply Darren.
Just thought I'd thank those for the feedback so far. I appreciate the suggestions and comments, but I still haven't resolved the issue. I'll keep trying.
Thank you
I am not much into Python, however you can try creating something like this:
Basically, create a Python script which will Join the feature class to the different database tables and then Export the output of the Joins as a new Feature Class to the desired SDE geodatabase, for publishing.
Thanks Asrujit for the suggestion. I'll give that a try.
Hi Ryan,
Another option you might try in python is arcpy.AddJoin. It works like Join Field but since it operates on in-memory features it works much much faster. I converted a model that used Join Field last week that took approximately 3 hours to run. Now using AddJoin it runs in 2.5 minutes.
Brandon
Thanks for the suggestion Brandon, I'll test arcpy.AddJoin out. I have 7
tables joined to the feature class I'm trying to export to SDE and the
script has been running a good hour and a half and its still chewing on the
7th join. Thanks you for the advice!
Ryan