[postgis-users] polygon count using MULTIPOINT

John Deck jdeck at berkeley.edu
Wed Mar 22 09:18:50 PST 2006


Suppose I want to count the number of times points within a  
collection (multipoints) fall within a polygon.  I tried the  
following query and the count always comes up 1 for every county,  
even though there are two identical points in the collection & SANTA  
CRUZ COUNTY should have 2 hits.

val=# select county,count(*) from us_county where distance 
(GeomFromText('MULTIPOINT(-122 37, -120 40,-122 37)',4326),the_geom) 
=0 group by county;
       county       | count
-------------------+-------
SANTA CRUZ COUNTY |     1
LASSEN COUNTY     |     1
(2 rows)

Any clues as to how to do this query  properly?

Thanks,
John Deck




More information about the postgis-users mailing list