Select to view content in your preferred language

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

1122
3
Jump to solution
06-20-2017 12:54 AM
EllenWildig
Deactivated User

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

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

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

View solution in original post

3 Replies
DanPatterson_Retired
MVP Emeritus

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

EllenWildig
Deactivated User

Fantastic, thank you!

0 Kudos
DanPatterson_Retired
MVP Emeritus

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

0 Kudos