I am iterating through a point shapefile to assign the points to buffer zones that they fall within, because some points fall within several buffer zones I am doing this using the Append tool into a pre-made shapefile so I will have a copy of each point for every buffer zone it is in. I have this set up in ModelBuilder currently using the Clip tool to 'clip' my points by my buffer, if the output is empty I move on, and if it is not then I assign the new points the buffer ID and append them to my final point shapefile.enter image description here

However it is running very slow and I have about 11,000 buffer zones in total to get through. Previously I had been using Select By Location on my points instead of clip, but I realized that if no points were selected (as happens with this data set) then ALL of my point are assigned that buffer ID and appended to my final shapefile. I need to find a way to prevent the Calculate Field and Append tools from running if no rows are selected, but I can't seem to make that work. I know the Get Count tool would only work for that if I was using the Select tool, is there any other way to work this? Is there a Get Count but only for selected rows?

This leg of my model seems to be the slowest one.

  • Get_Count like all the other tools returns only the selected records however if there isn't a selection it will return all of them. You will need to get an Original Count and a Select Count then branch if Select Count > 0 and Select Count < Original Count (use Calculate Value). I find this type of iteration is so much easier to code in python than to do in model builder with Get Count. – Michael Stimson Jul 14 '15 at 5:09
  • 1
    I too much prefer to work in python, especially with iteration (Model Builder iterators are frustrating in my opinion), however this is not my project, I was tasked with building and annotating a model for a PhD student to learn from. I tried to explain learning from an annotated python script would be easier but this is the way I have to do it. Thanks for the tip! – AlmaThom Jul 14 '15 at 19:07
  • I share your opinion on model builder iterators. Sorry I can't be more helpful; every time I anticipate an iteration I start with python and only create models that do not iterate. IMO models were supposed to be a simple way for non-programmers to create a process, a teaser for scripting, which would coax the user into exporting the script to python and iterating there. Trying to iterate/complicate a model is bordering on exceeding the scope of what models are supposed to do. You would think that a PhD student would be eager to learn python! – Michael Stimson Jul 14 '15 at 21:47

If you have the spatial analysis extension, you should be able to get good results with the spatial join tool using a one-to-many operation.

eg. arcpy.SpatialJoin_analysis(points_file, buffers_file, output_file, "JOIN_ONE_TO_MANY")

You can also choose which fields you would like to keep, so you can just keep the field which identifies the buffer.

  • Thank you! I knew there was a tool I was forgetting and that was it. I didn't have the Spatial Analysis extension for a long time and it slipped my mind what was in it. – AlmaThom Jul 14 '15 at 19:16

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.