[postgis-users] Help determining position

Surya Tarigan surya.tarigan at yahoo.com
Sun Oct 18 21:04:29 PDT 2009


Simon,

Thanks for the SQL, I will first figure it out and then exercise it on my dataset. It seems that to be able to use previous SQLs, I needed to merge/clean first my linestring in order to get exactly two rows for each river. By the way, river mouth means the start point of the river banks. 

kind regards,

surya



________________________________
From: Simon Greener <simon at spatialdbadvisor.com>
To: PostGIS Users Discussion <postgis-users at postgis.refractions.net>
Sent: Mon, October 19, 2009 10:17:34 AM
Subject: Re: [postgis-users] Help determining position

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
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



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


More information about the postgis-users mailing list