I am trying to create a model, using model builder, that will back up multiple files under certain conditions. The files being backed up are .sde files and I need them to be backed up as .shp files. I am using the "Feature Class To Shapefile (multiple)" conversion tool to accomplish this.
The conditions I need to meet include: 1. Keeps current file names 2. Overwrites existing files 3. Only backup files which have been modified since the previous backup
Currently, using the "Feature Class to Shapefile (multiple)" conversion tool, I have been able to meet my first two conditions; however I have not been able to figure out how to satisfy my third condition or if their is a tool capable of doing this.
I would appreciate any advise on how to solve this issue. THANKS! Marie
You don't get what you want for 2 and 3 with Feature Class to Shapefile (multiple).
2. The tool does not override if a file already exists. It appends an underscore and a number to the name. So, if rivers.shp exists then the tool, when you try copy again, will name the data rivers_1.shp
3. The tool does not compare states.
For the 3rd condition you can use Feature Compare tool. For doing that your workflow will be:
- Make copies (using Copy Features in batch mode) of all original data to a base SDE location. These will be your base data to compare with. Ideally, base data should be in SDE workspace.
- As Feature Class To Shapefile will not override your existing data, I would suggest using Copy Features in batch mode.
- When updating (if you don't use SDE base data): first compare SDE current data with the base SDE data (using, for example, Feature Compare). If a dataset is changed the tool will return False in which case copy that data as a shapefile to the folder. Also, update the base data with the changed SDE data.
Try the feature Compare tool in your model. I am assuming you are using the Feature Class Iterator in your model to iterate and copy your feature classes. Use the Feature Compare tool and for the test feature class parameter (open the tool dialog. It is the second parameter) give the path to your workspace that already contains the feature classes from previous backup : some thing like this C://Backup/%Name%. This %Name% is the variable name of the output of the Iterator. As long as the feature classes you are copying and the feature classes that already exists share the same name this will work. For the first time you can just copy the feature class without worrying about copying only the feature classes that have been modified.
One of the outputs of the feature compare tool is Compare status which becomes false if the feature classes you are comparing are different. You will have to set an if-then-else condition here to say if it is false run the feature class to shapefile tool, else do nothing. There is a series of blogs on if-then-else blogs that will help you.
The base data I am using are .sde files in a sde location. When I try to make copies (using Copy Features) of the original .sde data, with my output location outside of the sde database, I am returned an error (which says, "A locator with this name does not exist."). I need the output location to be outside of the sde database, which seems to be causing the problem.
Am I doing something wrong or is there something I can do to make this work?
Hi. I'm helping Marie get this project done in her office. We have the compare tool working and it outputs two items - 1. Output compare, and 2. Compare status.
Compare status is a boolean. How exactly do we connect that to the rest of the model that executes? Do we create an if-then code block and then draw a line from the Compare Status to it? And what should go in the if-then code block? We're trying to get it to work, but keep hitting dead ends.
What values you are setting for your Compare Status output? I guess True/False. Just connect your next step to this output. When you run your model the subsequent steps will only be executed if the status is True.
Did you try the if-then-else blogs? Please try the Part 1 using Calculate Value tool.
One of the outputs of the feature compare tool is Compare status which becomes false if the feature classes you are comparing are different. You will have to set an if-then-else condition here to say if it is false run the feature class to shapefile tool, else do nothing. The sequence of tools would be
Calculate Value with if-then-else condition. Connect the output of feature compare tool to the calculate value tool as a precondition. Pass the variable name of the output as inline variable in the Calculate Value tool like this %Compare Status%. See examples in the Part 1 blog. Your code has to say if the variable value is false return true. Set the data type parameter of the Calculate Value to Boolean.
Feature Class to Shapefile tool with the output of the Calculate Value tool connected to the Feature Class to Feature Class tool as a precondition.