Geospatial Modelling Environment

countpntsinpolys (Count Points In Polygons)

Counts the number of points that overlap each polygon, and writes the result to a field in the polygon attribute table


This tool counts the number of points that overlap each polygon, and writes the result to a field in the polygon attribute table. Each polygon is processed consecutively and independently of any other overlapping polygons. Thus, if there are overlapping polygons a single point may contribute to the count of more than one polygon, and the count for a polygon that is ‘underneath’ an overlapping polygon will not be influenced by this overlap.

This tool will also optionally weight the count by a value in a field in the point attribute table. In other words, rather than simply count the number of points, the tool will sum the weights and write that value to the polygon attribute table rather than the count. If the tool is writing a count the new field that is added will be an integer field, but if the tool is writing a weight value the new field will be a double precision field type.

Note that if the output field specified already exists then an error message is raised and the program will stop.


countpntsinpolys(poly, pnt, field, [weight], [where]);

polythe input polygon data source
pntthe input point data source
fieldthe name of the new field to add (must not already exist)
[weight]if specified the point counts are weighted by the values in this field in the point attribute table (i.e. the weights are summed)
[where]the selection statement that will be applied to the polygon feature data source to identify a subset of polygons to process (see full Help documentation for further details)


countpntsinpolys(poly=”C:datacounties.shp”, pnt=”C:datawells.shp”, field=”WELLCNT”);

countpntsinpolys(poly=”C:datahomeranges.shp”, pnt=”C:datakillsites.shp”, field=”KILLCNT”, weight=”KILLTYPE”);


Please consider making a purchase to support the continued development of these tools  Read more...

Tips on how to use this interface efficiently 


Open Source GIS

Copyright © 2001-2014 Hawthorne L. Beyer, Ph.D., Spatial Ecology LLC    Connect on LinkedIn