<div dir="ltr">Hey that's perfect. <div>The only thing when I use the array_agg is that I normaly get this:</div><div><br></div><div>"{"Moth Theatre Company"}"<br></div><div><br></div><div style>but in some cases I get this:</div>
<div style><br></div><div style>"{"Sacred Fools Theater Company","Sacred Fools Theater Company","Sacred Fools Theater Company"}"<br></div><div style><br></div><div style>Any idea why this happens?</div>
<div style>Thanks</div><div style>Carsten</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/11 Nicolas Ribot <span dir="ltr"><<a href="mailto:nicolas.ribot@gmail.com" target="_blank">nicolas.ribot@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
you could store initial information in a array of values of<br>
desc_string or other attribute, using array_agg function (or create a<br>
concatenated string using string_agg function):<br>
<br>
...<br>
SELECT a.poi_id,<br>
    a.geom,<br>
    array_agg(desc_string) as descs,<br>
    St_collect(b.geom) AS b_geom<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
Nicolas<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 11 October 2013 13:16, Carsten Hogertz <<a href="mailto:carsten.hogertz@gmail.com">carsten.hogertz@gmail.com</a>> wrote:<br>
> Thanks Hugues,<br>
> you helped alot. I added some text to your SQL like the following:<br>
><br>
> WITH myselect<br>
><br>
>     AS (SELECT a.poi_id,<br>
><br>
>     a.geom,<br>
><br>
>     St_collect(b.geom) AS b_geom<br>
><br>
> FROM<br>
><br>
>     ciss_poi a, ciss_poi b<br>
><br>
> WHERE<br>
><br>
>     St_dwithin(a.geom, b.geom, ( 0.5 / 111.111 ))<br>
><br>
>     AND a.poi_id != b.poi_id<br>
><br>
>     AND a.desc_string = b.desc_string<br>
><br>
> GROUP BY<br>
><br>
>     a.poi_id, a.geom)<br>
><br>
> SELECT ROW_NUMBER() over (order by geom) as id,<br>
><br>
>     St_centroid(St_convexhull(St_collect(geom, b_geom))) as geom<br>
><br>
> FROM<br>
><br>
>     myselect m<br>
><br>
><br>
> With this statement I get the centroid of the grouped point's convex hulls.<br>
> Obviously only the geography.<br>
><br>
> What can I do to label the information of one of the "initial" points that<br>
> formed the convex hull to the new centroid?<br>
><br>
><br>
> Best Regards and thank you very much<br>
><br>
> --<br>
><br>
> Carsten<br>
><br>
><br>
><br>
><br>
><br>
><br>
> 2013/10/11 Hugues François <<a href="mailto:hugues.francois@irstea.fr">hugues.francois@irstea.fr</a>><br>
>><br>
>> I think the problem is a bit more complicated. The self join is the good<br>
>> approach but you can't collect the boolean output of st_dwithin. I should<br>
>> have tried something like<br>
>><br>
>> with myselect as (<br>
>>     select <a href="http://a.id" target="_blank">a.id</a>, a.geom, st_collect(b.geom) as b_geom from mytable a,<br>
>> mytable b<br>
>>     where st_dwithin(a.geom, b.geom, 500)<br>
>>     and <a href="http://a.id" target="_blank">a.id</a> != <a href="http://b.id" target="_blank">b.id</a><br>
>>     group by <a href="http://a.id" target="_blank">a.id</a>, a.geom<br>
>>     )<br>
>><br>
>> select <a href="http://a.id" target="_blank">a.id</a>, st_collect(geom, b_geom) from myselect<br>
>><br>
>> Hugues.<br>
>><br>
>> ________________________________<br>
>> From: <a href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a><br>
>> [mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a>] On Behalf Of Carsten Hogertz<br>
>> Sent: Friday, October 11, 2013 9:30 AM<br>
>> To: PostGIS Users Discussion<br>
>> Subject: [postgis-users] ST_Collect<br>
>><br>
>> Hello,<br>
>><br>
>> I've got a question about using ST_Collect.<br>
>><br>
>> I have one table with hundrets of thousands of points. Within this table I<br>
>> want to collect the points that are within a 500 meter radius and calculate<br>
>> a convex hull around them.<br>
>><br>
>> Since the ST_DWithin needs (geom, geom, distance) and I only have one<br>
>> table with points, do I first have to perform a self join to identify the<br>
>> points within 500 meters and then a ST_Collect to group these points? Or can<br>
>> I somehow do it without joining the one table with itself?<br>
>><br>
>> And can I use the ST_DWithin inside the ST_Collect? Like<br>
>> ST_Collect(ST_DWithing(geom,geom,distance))?<br>
>><br>
>> Thanks for your help!<br>
>> --<br>
>> Carsten<br>
>><br>
>> _______________________________________________<br>
>> postgis-users mailing list<br>
>> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
>> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br></div>