I have a feature class of polygons and another of many points, and the points have a date field that I'm interested in joining to the polygons. However, I only want to join the oldest date from all of the point features that intersect each polygon. My thought process is that I'd do something like this:
1) Spatial join a unique identifier from the polygons to the points
2) Create a subset of the points feature class containing the oldest date points for each unique polygon ID
3) Join the dates of the new point feature class back to the polygons
Does anyone have any suggestions how to accomplish step 2? Or if there's a completely different method, I'm open to that as well. I'm using 10.2.
I've accomplished this somewhat manually previously by exporting the points to a spreadsheet, sorting them by date, and then doing a VLOOKUP for each polygon so that the first point match it finds is the oldest date for that polygon. But I'd really like to have this process as part of a larger model.
A little bit, but what I don't have any experience in is how I would integrate that with the existing model. Were you thinking something like a dictionary of the polygon ID and the date, and then comparing each date for each point with the same polygon ID, and updating the date value if it's older?
How I see it is:
1.Create a dictionary with polygon IDs as Keys, and a list of datetimes as Values - using a cursor to evaluate geometry(SHAPE@).disjoint .
2.run through all the Keys in the dictionary with a simple sorted() list of the values, and grab the first index (they are datetime objects than can be ordered, probably best to create another dictionary with key as ID and value as that lowest date value)
3.a final update cursor to replace the date value for matching polygons IDs