# Group every near 50 points together

6290
10
05-16-2017 01:44 AM
New Contributor III

Hi All,

I have a point FC I want to group every near 50 points together.

I tried:
1-Near tool or generate near table tool but the overlap is a big problem.

2-Grouping analysis tool with K-means but the number of points within each group is varying depending on the spatial location.

what I want is every near 50 point together in one group and only one group might be less than 50 points.

I understand it might look something like this  (restrict 50 point group)

Thanks,

Tags (3)
1 Solution

Accepted Solutions
MVP Esteemed Contributor

There is a general solution of using the nifty generalized spatial sort available from the Sort tool (requires Advanced license).

Then, in the sorted point table put them into groups with the python expression

``````int(OBJECTID / 50)  # geodatabase (OIDs start with 1)

Whether the results are really what you want (as Dan points out) is another question.

10 Replies
MVP Esteemed Contributor

Showing your point pattern might be better.  Perhaps it isn't possible given your restriction and your data

New Contributor III

I am thinking maybe if I can do some equation on the variance of the coordinates.

EX: I sort the longitude column and add other column "RANK_X" holding sequence from 1 to the last row then I did the same for the Latitude adding "RANK_Y" column, and by summing those two rank columns "SUM_COORD"  I have a number that indicates the variance in coordinates if I sorted this column the first 50 suppose to be near to each other based on the variance of the coordinates.

However, it's not the best approach and not giving the needed result in all the cases. see example below:

Case1:

Case2:

do you think I might get something from this approach maybe enhance the result by adding something to the equation?

MVP Esteemed Contributor

I see a few of cases, some of which you have highlighted, where the points are indeed clustered and could form or be used to form, aggregated units.  I see far more cases where the linearity of the pattern is going to make meaningful clusters difficult... particularly if you are using a threshold of 50 points.

• So why 50 points? this hasn't been explained?
• These pints appear to be events collected along a linear network (road? perhaps?)
• What is the goal/purpose of the clustering?

Answers to these questions may provide more meaningful suggestions.  Sorting by longitude and latitude is not going to yield much in the way of useful information.  A 'minimum spanning tree' will provide connections that minimize the aggregated distance connecting the points, but this will be of little use if the points are indeed collected along a linear network.

MVP Esteemed Contributor

There is a general solution of using the nifty generalized spatial sort available from the Sort tool (requires Advanced license).

Then, in the sorted point table put them into groups with the python expression

``````int(OBJECTID / 50)  # geodatabase (OIDs start with 1)

Whether the results are really what you want (as Dan points out) is another question.

Esri Esteemed Contributor

I would go for the solution provided by Curtis Price . Just did a simple test with some random points and when you use the PEANO option for spatial sort it kinda makes sense...

Resulted in:

I did change the formula into:

``int((!OBJECTID!-1) / 50) +1‍``

... to get the appropriate distribution of the clases in a file geodatabase:

MVP Esteemed Contributor

Which still begs the question as to what type of 'distance' is needed.  The point locations look far from random and I suspect they are observations 'along' something which makes shortest/closest a whole different issue

New Contributor III

Thank you, Dan

The points indeed are events collected along street network.
50 point is a must as this is the main purpose or request.

New Contributor III

let me describe it like this each 50 location will be photographed by a drone,

each drone could only take 50 photos, no matter what is the distance to be crossed.
this is not the real case but it's something similar to this.