Random points with ID and DateTime from GPS-points

590
5
01-18-2018 06:17 AM
FrankHanssen
New Contributor III

I have a GPS-file with app 8000 positions. I want to create a random point for each of these positions. Each of the random points should have the same ID and DateTime as its corresponding GPS point-point. Only the coordinates should vary.

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus

A sample of the GPS file contents might clarify what you want to do with the existing coordinates and the form of the date-time data

0 Kudos
FrankHanssen
New Contributor III

OK, sorry I forgot that! 

Is it possible to use field calculator to calculate random XY-coordinates within the GPS dataset (based on its extent) ?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Assuming you don't want to completely randomize the point locations... that would be as easy as assigning random numbers within a range for both X and Y.

But if you just want to randomize their location within a range of values...

... just add new Long/lat fields ie X_rand, Y_rand and you can shuffle your existing coordinates by bit determined by you.

I will use the existing fields in the table rather than having to access the Shape field (which is possible, but has extra baggage)

You just need to do this for the 2 new fields, then add the table back in as an event layer

To use....

Python parser, in the expression box 

shiffle(!yourfield!, dxdy= "your desired max deviation as a number")

import random
def shiffle(x_or_y, dxdy=0.2):
    """randomly shuffle a point"""
    return x_or_y + random.uniform(-dxdy, dxdy)

‍‍‍‍‍
FrankHanssen
New Contributor III

Thanks a lot Dan, very good tip! Is it a way that I can do this randomly shuffelling within the extent of the GPS-dataset?

0 Kudos
DanPatterson_Retired
MVP Emeritus

if you know the extents, then the above code could be modified to check for it...

but with every ... BUT .... things get more complicated, so the question would be, how mission-critical is it that things stay within the total extent

Thoughts? 

If it is an absolute need (ie, gps points falling into water rather than land) then provide your extent values.

If it is 'nice' then I will leave that as a coding exercise for someone

0 Kudos