1

I was hoping I could get some pointers in how to approach this issue, which is tricky version of a spatial join. I have been searching and I can't find a particular solution to what I need.

I have two data sets of points with related attributes that include date and coordinates. I want to join the points in data set A (records of events) with the nearest neighbor in the data set B (records of animal locations). The catch is that I want to find a neighbor in B that is not only closest to A in space but also in time. Perhaps explaining the purpose of this might help visualize what I want to do.

I want to join each event in A with the animal in B that was closest to the location of the event AND closest to the date in which the event happened. I have searched options with spatial join and "join by group" in ArcGIS. Yet I haven't been able to match according to attribute date given that the dates will not match exactly in every case. Thus, that is why I am looking for the record that is closest to that date instead of matching records that have equal dates and why I can't create fixed groups according to specific dates. Also I have a huge data set of about 100,000 records.

This is how my data bases look like. I have removed columns and rows to make it easier to visualize:

Database A, animal locations

indiv_code  sex month   year    Local_date  treatment   perturbati  xx  yy
A   M   3   2014    04-03-14    E   B   492533.82430000000  7935470.32100000000
A   M   2   2016    25-02-16    E   A   506713.28360000000  7938586.99800000000
A   M   2   2016    25-02-16    E   A   506732.55540000000  7938504.00800000000
B   M   2   2010    22-02-10    E   B   549766.00000000000  7909026.00000000000
B   M   2   2010    22-02-10    E   B   550720.00000000000  7908986.00000000000
B   M   2   2010    22-02-10    E   B   551746.00000000000  7906541.00000000000
B   M   1   2015    14-01-15    E   B   545292.81210000000  7891203.71800000000
B   M   1   2015    14-01-15    E   B   545292.82570000000  7891209.25100000000
B   M   1   2015    14-01-15    E   B   545262.86540000000  7891176.12900000000
C   M   4   2013    08-04-13    E   B   482280.00000000000  7941062.00000000000
C   M   4   2013    08-04-13    E   B   482266.00000000000  7941174.00000000000
C   M   4   2013    08-04-13    E   B   481805.00000000000  7942360.00000000000

Data base B, events

OID_    Dateincident    Year    Longitude   Latitude
1   10-01-08    2008    556517  7875861
2   15-01-08    2008    549887  7878550
3   15-01-08    2008    547800  7883200
4   17-01-08    2008    555500  7884500
5   30-01-08    2008    553530  7877180
6   31-01-08    2008    560328  7874984
7   31-01-08    2008    556517  7875861
8   01-02-08    2008    560400  7875900
9   01-02-08    2008    550400  7880500
10  01-02-08    2008    560500  7881500
11  01-02-08    2008    551800  7886800
13  14-02-08    2008    566300  7887700
14  20-02-08    2008    570326  7890088
15  27-03-08    2008    662271  7837444

I was thinking R could be the appropriate tool for this spatial and temporal join. Does anyone have any idea on how I could go about this? I have read so much information on spatial join, nearest neighbor and still can't figure this one out. If this is possible in ArcGIS, I have an advance licence for ArcGIS for Desktop. If someone has an idea on how to do this in R and wants to help out, I can make a shorter sample of the data available to you.

closed as too broad by PolyGeo Aug 1 '17 at 22:58

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Check this gis.stackexchange.com/questions/185673/arcgis-near-by-group/… you need to modify query – FelixIP May 5 '16 at 20:49
  • Should be able to do it in either R or Arc (arcpy). Calculate distance and difference in time for all pairs (or a subset based on an upper limit). Then weight each (time and distance) to do an optimization for each event. – jbosq May 5 '16 at 21:00
  • 2
    "Closest to the location" AND "closest to the date" usually has no solution. To get any reasonable analysis done, you need to specify some kind of trade-off between distances in time and distances in space. – whuber May 6 '16 at 14:49
  • Thank you all for your insights! They will help me fine tune my intended analysis. – AnnK May 9 '16 at 9:08
  • If you still need help with this, then please choose which of R and ArcGIS Desktop you wish to ask about in this particular question so that both the question and any answers can be focused on that. – PolyGeo Aug 1 '17 at 22:58