[postgis-users] Query to find all stops surrounding 1 stop and turn it into a concave hull polygon geometry

Paragon Corporation lr at pcorp.us
Tue Apr 23 20:21:10 PDT 2013


Jo,
 
ST_ConcaveHull and ST_Collect work on a geometry and you are trying to apply
it to a record as the error says :)   ERROR:  function st_collect(record)
does not exist
 
PostgreSQL is funny as it allows you to pass around whole records to
functions so since you did
 
ST_Collect(surroundingstops)
 
you are passing the record not the geometry.  Try changing to
 
ST_Collect(surroundingstops.geomdl)
 
Hope that helps,
Regina
http://www.postgis.us
http://postgis.net
 

  _____  

From: postgis-users-bounces at lists.osgeo.org
[mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Jo
Sent: Tuesday, April 23, 2013 5:54 AM
To: PostGIS Users Discussion
Subject: [postgis-users] Query to find all stops surrounding 1 stop and turn
it into a concave hull polygon geometry


After a lot of trial and error I came up with this query:

SELECT ST_ConcaveHull(ST_Collect(surroundingstops),0.98)
 FROM (SELECT st1.geomdl 
        FROM stops st1
        WHERE ST_DWithin(st1.geomdl::geography, 
                         (SELECT st2.geomdl
                           FROM stops st2
                           WHERE st2.stopidentifier=203896
                            AND st1.osm_zone IS NOT NULL)::geography,
                          1000)) surroundingstops;


Unfortunately I get this error message:

ERROR:  function st_collect(record) does not exist
LINE 1: SELECT ST_ConcaveHull(ST_Collect(surroundingstops),0.98)
                              ^
HINT:  No function matches the given name and argument types. You might need
to add explicit type casts.



The subquery results in 1 column of geometry values. When looking at the
examples on

http://www.bostongis.com/postgis_concavehull.snippet

they always seem to be working with all the values in the table, but I only
want to get the shape of some of the stops in the DB, not all 43000 of them.
Later on, I want to group them by zone. The intention is to determine what
zone this stop belongs to. If it's surround by stops which all have the same
zone information, it would be safe to conclude this one is part of that
zone. When on a border between 2 zones it is not.

Should I create a temporary table to accomplish this? I tought
ST_ConcaveHull would enable me to go from a collection of point geometries
to 1 polygon geometry.


Jo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130423/15124d75/attachment.html>


More information about the postgis-users mailing list