Using Modelbuilder to Automate Select By Location

2839
3
01-04-2013 01:20 PM
MashhoodSyed
New Contributor
Hello,

Ive got my map divided into several polygons.  I have points located throughout these polygons.  Each polygon is a different shape and size and contains a unique number of points.

I want to extract a count of these points per polygon (output to a .csv format if possible).  I know how to do this manually using the Select By Location method but I am trying to build a tool that can do this for me automatically.  I have millions of points throughout my map and it takes a few hours doing it manually. 

I have started building a tool which ends up outputting another point file (that replicates the point file I use as the input)  instead of a file that just contains the counts (and other summarized data).  Cant seem to figure out what needs to change here?  My coordinate system is the same in the input and output.  I am using ArcMap 10.

Attached is the picture of my tool as it stands currently and the exported Python Script.
0 Kudos
3 Replies
JoshuaChan
New Contributor III
are you comfortable using python?

you could create a cursor to go through your polygon feature class, select the polygon, then do a select by location to get the points overlapped. The selected points can be counted and saved somewhere (text file, fgdb table, dbf etc)
then you would unselect everything and let your cursor start over with the next polygon
0 Kudos
by Anonymous User
Not applicable
Original User: msSOC

Hi.  Thanks for your reply.  I havent used Python yet, but wouldnt mind trying to.  Do you know of any sample code I can look at to build a cursor, as you mentioned?
0 Kudos
JonathanQuinn
Esri Notable Contributor
In your model, you've set it up correctly it seems like, but you're not doing anything with the results, so it overwrites them each time.  Look into using a model within a model and the Collect Values tool to gather the results from the iteration, and merge or append them or do whatever else you need to.  The section called "Advanced use of model iterators" should point you in the right direction.
0 Kudos