Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a situation in which I need to find how many points lie within a polygon, this would be quite simple with a summarized inside join from points to polygons except for the fact that the points have a time field and I only need to know only when the "point time" is in-between the "polygon start time field" and the "polygon end time field". Then I need the sum of all those points that meet that criteria and place into a new field of the polygon layer. I have around 3000 points and 2500 polygons (polygons overlap, thus needing the time constraint)

Logic: SUMofPoints (IF Point is over polygon AND IF Polygon Start Time < Point Time < Polygon End time)

All Point and polygon times are stored in a attribute field inside a geo-database. If it helps the times are formatted as "yyyymmddhhmm"

I have a feeling that this requires python (or maybe even model builder?) but I have no formal experience in python although I have resources to friends and professors who do. So as simple as possible would be nice, but I know these things aren't really that simple.

Any Hints, suggestions, places where I should look would be much appreciated.

Thank you in advance,
GIS Student, Millersville University

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

This is best suited for a python script, however you could accomplish it without scripting. As a trade-off, there are a number of steps though...

for simplicity I use integer fields for your time attribute

providing your shape file is not 3D (as this will use a dissolve which may alter Z values) you could try the following steps:

1) add an ID field to your polygon shape file that would store unique polygon IDs. You can calculate them for example, FID + 1

2) use a spatial join tool from within Analysis Tools\Overlay\Spatial Join within spatial join - target features: polygon, join features: points, join operation: JOIN_ONE_TO_MANY and match option: COMPLETELY_CONTAINS

3) open attribute table of the shape file obtained from 2) and add a new field. Right click on it and open field calculator. Make sure to select Python parser and check Show Codeblock. Inside Pre-Logic Script Code copy the following (indentation matters!):

def CheckIfIDIsWithin (fieldMin,fieldMax, field):
    if field >= fieldMin and field <= fieldMax:
        return 1
        return -1

then in your filed = copy the following CheckIfIDIsWithin (startID, endID, newfield) this will assign 1 or -1 based on whether the number falls within the start/end numbers

4) delete all features with newfield = -1

5) use a dissolve tool and for input features: output from 3, for dissolve fields select your unique polygon ID (as added in 1), for statistics field add polygon ID and then for statistic type select COUNT - this should give you the count of points that are within polygons and are within attribute range

6) finally join output from 4 with you polygon shape file to get all original attribution back if required

Hope that helps

share|improve this answer
add comment

Your Question seems to be quite similar to How to perform a join on simultaneous spatial and attribute criteria in ArcGIS? so my Answer is based on the one I provided there.

  1. Iterate through each unique time period in your polygons (using ModelBuilder or Python) one at a time to Select out your polygons and points for that time period.
  2. Run your Spatial Join on each time period's data
  3. Append your data for each time period into a dataset for all time periods
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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