I am working with GPS data and so I have UTM's with DATE/Time information. I have 2 groups of species (moose and wolves). I want to join the information from moose to wolves that match in time. So, location 1 from moose 1 was at 2007-03-26 14:33:49 to all wolves that were recorded at approximately the same time. Approximately is key - it means I will have to have a time window or buffer to look for all wolf locations that were within 30 minute buffer around that time.

I'm looking for a script or tool that will set a window buffer +/-X min and will be able to "batch" process. Ive at least 30 moose and 30 wolves - so doing the matching one pair at a time is not helpful. Once Ive got the date/time matched, I then want to calculate the distance between the XY locations of moose and wolf and the difference in time. I would like an output like:

individualmooseID | mooseDate | mooseX | mooseY | individualwolfID | wolfDate | wolfX | wolfY | Distance(m) | TimeDiff (min)

The mooseID may match up to several DIFFERENT wolfIDs for the same time period. Any suggestions would be appreciated. I have written a code for R but it is not working see my question: https://stackoverflow.com/q/15646365/675742 and I will have to bring the data into ArcGIS at some point so if I can skip R and do it all in ArcGIS then GREAT!

  • 4
    I successfully did this a long time ago by creating two layers whose coordinates were time plus an artificial value y, with y = 0 for one dataset and y = some constant for the other dataset. At this point you can use spatial joins, buffering, and other forms of spatial analysis to answer your question, because proximity in these artificial coordinates is the same as proximity in time. – whuber Mar 27 '13 at 16:04

Data sets like this can give very much information of course.

I would do this in a spatial database environment, preferably PostgreSQL/PostGIS.

What you want to do seems like a simple joining on both spatial and time data.

Then you do everything in one query. The tricky part might be to optimize the indexes for the time joining. I guess the data sets is quite big.

The query can look something like this (read it as pseudo code, especially the time-part))

SELECT DISTINCT ON (moose_id, wolf_id, moose_time) 
moose_id, moose_geom, moose_time, wolf_id, wolf_geom, wolf_time,
ST_Distance(moose_geom, wolf_geom) as dist, moose_time-wolf_time as time_diff
moose_table as mt inner join wolf_table as wt 
ST_DWithin(moose_geom, wolf_geom,10000) 
AND moose_time > ( wolf_time-30) 
AND moose_time < (wolf_time + 30) 
ORDER BY abs(time_diff), moose_id, wolf_id, moose_time;

two notes:
1) I used ST_DWithin to constrain on pairing wolf-mooses that is closer than 10000 meters. That is a way to decrease the calculating and not calculate every possible combination.
2) I used DISTINCT ON. For each moose-wolf combination on each moose time registration you should get only the distance when they were most close in time.

But I see several other interesting queries to test on your data set that should give interesting information about the way the wolfs hunt the mooses.

For instance you can, instead of finding the distance between the wolf and the moose when they are as close as possible in time find out when they are as close as possible spatially. That is just rearranging the ordering. Then, in the cases when the wolf is following the moose, you will see how far behind in time the wolf is. Of course it will be rough values since I guess that wolfs not only track but also go by wind drifting smell but in some cases you will see how far behind the wolf is, and how that is changing. Together with the speed of the wolf and the moose, that might give a good pattern of what is going on.

The speed you of course get from another simple query :-)

So, put you tables in a postgis database and do the job there.

If you are using ArcGIS 10 or 10.1 you can watch the data directly from the database. Or from QGIS. That is a more mature combination PostGIS-QGIS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.