Fantastic. That was exactly what i needed. I managed to get the count, but the ARRAY_AGG() was new to me.<div>A great function indeed.</div><div><br></div><div>Andreas<br><br><div class="gmail_quote">2010/9/30 Nicklas Avén <span dir="ltr"><<a href="mailto:nicklas.aven@jordogskog.no">nicklas.aven@jordogskog.no</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

        
        



<div>Something like this should work:
        
<div align="left"> </div>
        
<div align="left"> </div>
        
<div align="left"><br>
                SELECT count(*) as number_of_conflicts, array_agg(<a href="http://b.id" target="_blank">b.id</a>) as id_of_conflicts FROM conflict_zoones a , vector_grid b WHERE ST_Intersects(a.the_geom, b.the_geom) GROUP BY <a href="http://b.id" target="_blank">b.id</a>;</div>

        
<div align="left"> </div>
        
<div align="left">array_agg will give you an array looking something like:</div>
        
<div align="left">{13, 23, 54}</div>
        
<div align="left"> </div>
        
<div align="left"> </div>
        
<div align="left"> </div>
        
<div align="left">HTH</div>
        
<div align="left">Nicklas</div><div><div></div><div class="h5">
        
<div align="left"> </div>
        
<div align="left"><br>
                <br>
                2010-09-30 Andreas Forř Tollefsen wrote:<br>
                <br>
                Hi all,></div>
        
<div><br>
                ></div>>
        
<div>I have a table of circular polygons which represents conflict zones within countries and a global vector grid with 0.5 x 0.5 decimal degree grid cells (square polygons).</div>>
        
<div><br>
                ></div>>
        
<div>What i need to figure out is for each 0.5 x 0.5 grid cell, how many of these conflict zones intersect, and the ID of each of them.</div>>
        
<div>Preferably the result should be a column with the number of intersecting circular conflict polygons, and a column with the id of all of them separated by a comma.</div>>
        
<div><br>
                ></div>>
        
<div>I cannot get my head around how to structure this?</div>>
        
<div><br>
                ></div>>
        
<div>Any ideas?</div>>
        
<div><br>
                ></div>>
        
<div>Andreas</div>>
        
<div><br>
                ></div>>
        
<div><br>
                ></div>
</div></div></div>

<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
<br></blockquote></div><br></div>