1

I want to make a ModelBuilder tool that takes shapefiles from a specific folder and clips them. The shapefiles cover an entire country and I have to clip them to project areas when we have new projects.

It runs fine now, but it saves the files regardless of whether or not they are empty. Is there way to make it so that it does not save empty files?

ArcMap 10.8.1 enter image description here

1 Answer 1

0

You can't stop it from creating empty outputs, but you can clean up afterwards. Expand your model as shown below. If the output is empty (count = 0) then delete it. Note Row Count is a precondition link to Calculate Value and its output is a precondition link to the delete tool

Model

In Calculate you need this very simple python code check:

Calculate Value tool

4
  • How do I make it a conditional statement to where it will delete only the files with 0 rows? I made Row Count a precondition link, but it just counts the rows then deletes everything.
    – David
    Oct 19, 2023 at 14:10
  • Thanks for the update. I tried the same, but it's still not working for me. I tried two different areas where I know there is data to be clipped and it just deleted everything. I even tried the original tool I posted and found some of the layers did have data. Refreshed the GDB, but nothing...I see the logic but don't understand why it's not working. Do you have any ideas on why?
    – David
    Oct 20, 2023 at 11:59
  • Without access to your data and current model its not possible for me to comment as the above model works fine for me; keeps clipped data when there is data and deletes the empty feature class when there is no data.
    – Hornbydd
    Oct 20, 2023 at 13:34
  • Here's the tools execution. It reads correctly that there are 2 rows, but still deletes... Start Time: Thu Nov 2 13:52:50 2023 Row Count = 2 Succeeded at Thu Nov 2 13:52:50 2023 (Elapsed Time: 0.00 seconds) Executing (Calculate Value (2)): CalculateValue Check(2) "def Check(n): if n >= 1: return False else: return True" Boolean Start Time: Thu Nov 2 13:52:50 2023 Value = 0 Succeeded at Thu Nov 2 13:52:50 2023 (Elapsed Time: 0.00 seconds) Executing (Delete):
    – David
    Nov 2, 2023 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.