I am new to GIS models. I was preparing a very basic model which does the following task:
1.) Inputs 2 shapefiles
2.) Projects their co-ordinate system
3.) Repair Geometry
4.) Add Field(ID_no)
5.) Field Calculate for the field "ID_no."
Actually i want to apply if condition that if there is already a field named "ID_no" in the shapefile, don't add field else if there is not a field named "ID_no" in the shapefile then add the field.
Please help me out regarding how should I do this in GIS modelling as I am unaware of python.
I suppose that you have the rest of the model put together already, but are just looking for help with
..... branching.. if-else logic ...
Dan, good link, but the example in the help requires creation of a Python script tool. So does the example in the https://community.esri.com/docs/DOC-8931-if-you-are-stuck-at-if?sr=search&searchId=7fe48a5d-7146-451... blog posts.
To answer the OP: If the field already exists, Add Field will not throw an error, the tool it will throw a warning and the model will continue to run. I don't think you need an if branch.
Actually what exactly I wanted as a result of my model is that:
After the Add field, the next step is "Calculate Field" in which I copy the numbers same as FID.
This step i.e. "Calculate Field" is not working in case the field "ID_no" already exist.
What should I do in this scenario???????
This should work if the field exists or not if you connect the output of Add Field to Calculate Field.
Akhil,
For the specific case of the "Add Field" tool, you don't need an If..Else construct. The tool has been written to automatically skip adding a new field, and allow the model to continue, when there is an existing field with the same name as needs to be added, it will just emit a warning in the geoprocessing log, but continue.