Embark on a journey of data transformation with our latest blog post, where we delve into the realm of ModelBuilder in ArcGIS Pro. Join us as we guide you through the seamless automation of transferring multiple datasets into a file geodatabase. Starting from scratch, we'll help you create a project, establish a toolbox, and craft a model that aligns with your specific needs. Witness the power of organization as we name our toolbox and model with purpose, ensuring clarity and efficiency. Step by step, we explore the intricacies of adding files, creating a new geodatabase, and setting up loading functionality. The heart of our exploration lies in ModelBuilder, where we utilize Iterators and Geoprocessing tools to orchestrate a smooth data transfer.
In this article, we will develop a model that transfers multiple data into a database.
Create a project
Starting with a new blank project in ArcGIS Pro. From the project, we will choose to create a new toolbox. This is done by right-clicking on Toolboxes from the Catalog pane.
We name the toolbox, choosing Upload_files.atbx as the name.
So far we have created an empty container, now we need to create our model.
Create a new model.
This is done again by right-clicking on our toolbox.
Our first model is ready. As you can see on the screen it is empty and with a default name.
Let's give it an appropriate name to match its purpose.
In one toolbox, to contain multiple models and scripts.
Of course, it is good to organize them according to their purpose.
We select with the mouse button the newly created model and indicate Properties.
Two names are available, the name that will be displayed to the user and the name under which the model will be stored and we confirm with OK.
To display the updated names, select the model save.
Now let's look at the files we will import. For this purpose, from folders I add the folder with the working files in my case in shape format. Let's take a look at them.
Now let's create a new geodatabase into which we'll transfer all the files in bulk.
Create a new geographic database
This is done by selecting a database, with the right button we select a new database.
We assign a name to the database.
At this point, the database is empty and cannot be expanded to view its contents.
Create loading functionality.
Now it's time to create our model. We go to the ModelBuilder window and select Iterators from the menu.
Since we will be loading files we need Iterate Feature Classes.
Iterators has been added to the project but is inactive. Now we need to make settings for file paths and names.
Double-click on Iterate Feature Classes.
A view similar to the geoprocessing window opens.
As you can see the folder path selection is a required parameter, let's add it by clicking on the folder.
If the main folder contains subdirectories with folders, we choose Recursive, which in practice means to search for files and the contents of the subfolders.
The tool contains two very useful settings that we will look at later. These are Wildcard to search by part of the file name and Feature Type to select a file by geometry or table type.
Confirm with OK.
Now our model is active. We can even run it to test what it will do.
We validate from the validation button.
Save the changes. Note that the recording is always manual and chosen by you.
We launch and review the result.
Of course, the execution of the model is done with the RUN button. As a short cut is also available.
The model is marked with a shadow next to each block as completed.
Let's review our database.
Of course it's empty.
What we have accomplished so far. We made a model that accesses a folder of files. It crawls that folder and reads the files, as you can see from the message window above.
But we haven't specified what to do with these files. For this purpose, we need to choose a tool that will transfer our files to the file database we created.
Work with geoprocessing.
We will use the Feature class to Feature class tool. We are looking for it in the geoprocessing window.
Drag and drop to add it to our model.
As you can see from the picture, the new block is marked in gray. Now we need to connect the two tools.
This is done by dragging the arrow and the green block to Feature Class To Geodatabase. We select Input Feature. This practically means that the output from the previous tool will be the input for the Feature Class To Geodatabase.
Now we need to set up the output of the processing. At this step, we need to specify two things the name of the database and the names of the files. By double-clicking on Feature Class To Feature Class, we access the settings menu.
For Output location we choose Upload_files.gdb
For name we specify a dynamic variable %Name% which practically means take the name from the blue block and assign it as the name of the outgoing class in the DB.
We close with OK. Again we validate and save our model.
Model execution
We start from Run, the transfer of the files begins.
We are waiting for it to finish processing and we will check our database.
We navigate to the database and select refresh with the right mouse button. When transferring multiple files, we need to refresh the workspace for them to appear.
View database contents.
Congratulations, you have a completed data processing model.
Add parameters to a model
Let's make a few more simple tweaks to use this model in more situations.
For this purpose, we will set several parameters.
We can open our model with a double click. It is a geoprocessing made by us. But as you can see from the screen we have no possibility to control the input and output from it. In other words, on each run, it will always do the same operations of taking files from the specified folder and transferring them to the selected geodatabase.
We save the changes and view the press geoprocessing window.
Let's add by names for the user, what he should select in the two windows. With rename we name the input files
For the output database we specify output gdb
We validate and save the model. Let's open it again by double-clicking on the model in the geoprocessing window.
We now have correctly added names for input and output. These parameters are dynamic and our model is reusable.
For example, I can set for an incoming file.
This processing will take all the files from the 10m_cultural folder and transfer them to Default.gdb
A warning message is displayed because there are corrupted files. You can see more from View Details.
Let's review the result.
In addition, we can return to both parameters from earlier. Let's force them to be accessible by the user. This is done by right-clicking on Iterate Feature Class.
We repeat the operation for Feature Type
Now we need to make them right click parameters.
We validate and save, we now have two additional parameters for geometry type and symbols in the name.
Launching a new geoprocessing tool
For example, let's select all the lines that contain the name land
Let's review the result in the database
As we expect they are added only the filtered layers that match the query.
Thanks for your attention, for more posts subscribe to our newsletter.