Python point neighbor processing ideas?

4841
13
Jump to solution
04-30-2015 06:38 AM
ClintonCooper1
New Contributor III

I know a bit about python scripting, but am having some trouble figuring out where to get started on creating a script.

I need to loop down through a dataset (about 10,000 records), and select all points within a certain distance of the current point in the loop (it doesn't have to be a selection, but it must be within a spatial distance of the current point I just figured a selection would be good because it would limit the number of points that are queried).  After I create the selection of points,I need to count the number of points that satisfy 2 criteria:  1) have a value in another field 1 that is the same as the value in of the current point's field 1; 2) have values in field 2 that are greater than the current point's field 2.  I also have to do anther count that has the same above criteria of 1), but instead of greater than, I need to count those that are less than the current point's value in field 2.   I then need to print those counts (both greater than and less than) as well as the current point's  id  so I can go back and put them in another table for analysis.

I guess I would kind of be looking for an outline or some code that might be able to help get me started writing it.  Thanks!

(Curtis Price edited title [originally: "Python Script help"] (4/29/2015))

0 Kudos
13 Replies
curtvprice
MVP Esteemed Contributor

You may want to look at the Spatial Analyst tool Point Density.

curtvprice
MVP Esteemed Contributor

I would try the Point Distance tool and then do processing on the output table. This can make a very big table but if you limit it with a search distance that keeps it from getting too big.

I've found Python sets and dictionaries to be very helpful for this kind of processing -- so you may run Point Distance, Add Join, load data into python objects using an arcpy.da.SearchCursor loop.

I 'm thinking Select by Location sounds straighforward -- but it would be a prohibitively slow approach if you have a significant number of points to process.

DarrenWiens2
MVP Honored Contributor

You do most of your task using Spatial Join on the point file itself, as both Target and Join Features, ONE_TO_MANY, WITHIN your distance. In the output, select and delete points where TARGET_FID = JOIN_FID (that is the point joined to itself). You can then select the matching rows which meet your criteria, and count using Summary Statistics, grouping on TARGET_FID.

ClintonCooper1
New Contributor III

I like this solution a lot, thank you!!!