[postgis-users] Help determining position

Simon Greener simon at spatialdbadvisor.com
Sun Oct 18 20:17:34 PDT 2009


Surya,

> with help of the list I am able to determine minimum width of a river using SQL below. Especially thanks to Mr. Simon Greener.. I still need to determine position (in meter and also latlon) of this point from the river mounth. Can anybody give me suggestion what Postgis function I should use together with the following SQL.

Not going to do everything for you (after all you have not supplied us a definition of the river mouth), but I would probably start by trying to find the actual points in the left/right bank that are closest via something like this:


-- Which points are closest to each other?
--
SELECT l.rin,ST_Point((l.coord).x,(l.coord).y),
        r.rin,ST_Point((r.coord).x,(r.coord).y),
        ST_Distance(ST_Point((l.coord).x,(l.coord).y),
                    ST_Point((r.coord).x,(r.coord).y)) as PDistance
   FROM (select row_number() over (order by the_geom) as rin,
                ST_DumpPoints(the_geom) as coord
           from River r
          where r.Name = 'Barito' ) as l,
        (select row_number() over (order by the_geom) as rin,
                ST_DumpPoints(the_geom) as coord
           from River r
          where r.Name = 'Barito' ) as r
  WHERE l.rin <> r.rin
  ORDER BY 5 ASC
  LIMIT 1;

Note, the ST_DumpPoints() function is a user defined one you can get from http://www.spatialdbadvisor.com/postgis_tips_tricks/109/implementing-oracles-getvertices-function-in-postgis-st_dumppoints

But this will return the left and right points that are closest. Then you need to calculate the distance from each point to the point that defines the mouth of your river and chose the closest.

regards
Simon

-- 
SpatialDB Advice and Design, Solutions Architecture and Programming,
Oracle Database 10g Administrator Certified Associate; Oracle Database 10g SQL Certified Professional
Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius Topology and Studio Specialist.
39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
Website: www.spatialdbadvisor.com
   Email: simon at spatialdbadvisor.com
   Voice: +61 362 396397
Mobile: +61 418 396391
Skype: sggreener
Longitude: 147.20515 (147° 12' 18" E)
Latitude: -43.01530 (43° 00' 55" S)
GeoHash: r22em9r98wg
NAC:W80CK 7SWP3



More information about the postgis-users mailing list