2

I am trying to create a model in ArcGIS that copies the feature classes which are stored in SDE geodatabase “SQL” to file geodatabase “in order to sync my SDE data to FGDB“, here what is the best practice to do this, I mean I am trying to use copy features tool, but It seems not efficient because of the following reason which is that I have 10 feature classes stored in my sde database so I need to use copy feature 10 times with 10 parameters and if one of my F.C was renamed then I should edit the model again , If there is any tool or method that copies the whole sde to FGDB

1

The easiest way is to use "Iterate Feature Classes" tool in Model Builder. You can access it from:

Insert > Iterators > Feature Classes

If you want to copy all feature classes, leave WildCard and Feature Type parameters empty, and just set the Workspace.

  • Hi Alex and Farid, Both of your answers is right, @Alex I didn’t got you when you said “and you shouldn't care if any changes occur in the SDE geodatabases” and also I would take the model choice to do the job since I have no experience in python scripting despite the fact that python is much faster than a model. – Ahmad saleh Apr 11 '15 at 15:55
2

The best way to handle this in ModelBuilder is to use the Iterate Feature Classes tool. It will find all the feature classes in the specified workspace (such as SDE geodatabase) and create an iterable list which you can then process with the Copy Features GP tool. The Copy Features will all the feature classes one by one, and you shouldn't care if any changes occur in the SDE geodatabases.

Alternatively, you could use the arcpy's ListFeatureClasses function if you are comfortable with Python. It might be actually way faster to write a Python script that will copy the feature classes between the geodatabases comparing to building a model. Look at the samples here:

HowTo: Automate copying datasets from one database to another

  • But How to delete the feature classes in the file geodatabase automatically, beacuse if I run the model and the target Geodatabase contains the old feature classes the model breaks and fails to replace the new features with the old one ?! – Ahmad saleh Apr 11 '15 at 18:47
  • 1
    Add a new iteration before copying that will delete the feature classes. Alternatively, use the if (resources.arcgis.com/en/help/main/10.1/index.html#//…) statement to see if a feature class exists first and then if yes >>> delete it. – Alex Tereshenkov Apr 12 '15 at 7:31
  • Thanks Alex, Adding more than one iterator to the model is not supported in the model builder, But I overcome this issue by inserting sub models which have iterators to do this job, thanks a gain for the prompt help. – Ahmad saleh Apr 12 '15 at 18:47
  • No problem, if you have a chance - learn arcpy. You will see that it is so much better suited for this kind of job (imho) – Alex Tereshenkov Apr 12 '15 at 18:48

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.