# Can you force an existing point dataset to move to within a minimum distance of one another?

773
3
06-20-2017 12:54 AM
New Contributor III

I know I could shift the points one by one, but there are over 6000 existing points. Is there a way to have them all move so they remain as close as possible to their current location but fall no closer than say, 5m of one another?

Thanks

Tags (4)
1 Solution

Accepted Solutions
MVP Legendary Contributor

The quickest way would be to add two new fields to your point table and calculate an Xnew and Ynew field which takes the form of

``````from random import uniform
def shift(val, start=-1, end=1):
"""shift within the range +shifty and -shifty"""
jiggle = uniform(start, end)
return val + jiggle‍‍‍‍‍‍‍‍‍‍``````

Now if val was 10, then you would get numbers in the 9-11 range.

Just repeat for the X and Y coordinates.

The 'val' can be provided from an appropriate X or Y field or you could use !Shape.centroid.X! and !Shape.centroid.Y! instead.

The expression box is

shift(whateverYouUseForVal, start=-1, end=-5)  # you can mix up the start and end ranges, they don't need to be equal

EDIT

I failed to state the obvious... add the new x,y data back into arc* and save it as a shapefile/feature class

3 Replies
MVP Legendary Contributor

The quickest way would be to add two new fields to your point table and calculate an Xnew and Ynew field which takes the form of

``````from random import uniform
def shift(val, start=-1, end=1):
"""shift within the range +shifty and -shifty"""
jiggle = uniform(start, end)
return val + jiggle‍‍‍‍‍‍‍‍‍‍``````

Now if val was 10, then you would get numbers in the 9-11 range.

Just repeat for the X and Y coordinates.

The 'val' can be provided from an appropriate X or Y field or you could use !Shape.centroid.X! and !Shape.centroid.Y! instead.

The expression box is

shift(whateverYouUseForVal, start=-1, end=-5)  # you can mix up the start and end ranges, they don't need to be equal

EDIT

I failed to state the obvious... add the new x,y data back into arc* and save it as a shapefile/feature class

New Contributor III

Fantastic, thank you!

MVP Legendary Contributor

Ellen, if it worked, could you mark the question answered so that people will know that a solution was provided.