<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV>Dear Simon,</DIV>
<DIV> </DIV>
<DIV>Thank you for the clue. I tried the SQL taht you proposed:</DIV>
<DIV> </DIV>
<DIV>select row_number() over (order by the_geom) as rin, the_geom<BR>  from River r<BR>  where r.Name = 'Barito';</DIV>
<DIV> </DIV>
<DIV>it gives error message : syntax error at or near "over"</DIV>
<DIV> </DIV>
<DIV>Could it be caused by PostgreSQLv ersion  8.2 that I am using? </DIV>
<DIV> </DIV>
<DIV>kind regards,</DIV>
<DIV> </DIV>
<DIV>surya<BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Simon Greener <simon@spatialdbadvisor.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> PostGIS Users Discussion <postgis-users@postgis.refractions.net><BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Wed, October 14, 2009 11:03:34 AM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [postgis-users] polygon minimum width<BR></FONT><BR>Your query is not distinguishing between the left and right river linestring.<BR><BR>If there were TWO of them sharing the same name and ID then one way to do this using PostgreSQL 8.4 is:<BR><BR>drop table river;<BR>create table river (<BR>  id integer,<BR>  name varchar(32),<BR>  the_geom geometry<BR>);<BR><BR>insert into river (id,name,the_geom)<BR>values (1,'Barito',ST_GeomFromText('LINESTRING(-237.5 -138.5, -79.5 -31.5, -119.5 101.5, 41.5 166.5, -51.5 251.5)',0)),<BR>       
 (1,'Barito',ST_GeomFromText('LINESTRING(42.5 271.5, 216.5 163.5, 70.5 84.5, 4.5 -4.5, -39.5 -58.5, -79.5 -151.5, -40.5 -243.5)',0));<BR><BR>select *<BR>  from river;<BR><BR>id;name;the_geom<BR>integer;character varying;geometry<BR>1;"Barito";"010200002000000000050000000000000000B06DC000000000005061C00000000000E053C00000000000803FC00000000000E05DC000000000006059400000000000C044400000000000D064400000000000C049C00000000000706F40"<BR>1;"Barito";"0102000020000000000700000000000000004045400000000000F870400000000000106B4000000000007064400000000000A051400000000000205540000000000000124000000000000012C00000000000C043C00000000000404DC00000000000E053C00000000000F062C000000000004044C00000000000706EC0"<BR><BR>SELECT min(ST_Distance(r.the_geom, r.the_geom)) as Min_Width<BR>  FROM River as r<BR>  WHERE r.Name = 'Barito';<BR><BR>min_width<BR>double precision<BR>0<BR><BR>The above SQL is, for each row it selects,  pushing the same geometry into the
 ST_Distance function.<BR>What we need to do is feed the left and the right linestring into the same function as follows. Firstly we<BR>need to give each row its own unique id....<BR><BR>select row_number() over (order by the_geom) as rin, the_geom<BR>  from River r<BR>  where r.Name = 'Barito';<BR><BR>rin;the_geom<BR>integer;geometry<BR>1;"010200002000000000050000000000000000B06DC000000000005061C00000000000E053C00000000000803FC00000000000E05DC000000000006059400000000000C044400000000000D064400000000000C049C00000000000706F40"<BR>2;"0102000020000000000700000000000000004045400000000000F870400000000000106B4000000000007064400000000000A051400000000000205540000000000000124000000000000012C00000000000C043C00000000000404DC00000000000E053C00000000000F062C000000000004044C00000000000706EC0"<BR><BR>Now we can use this to separate our river into its two halves and then, via a cross join, feed them into the ST_Distance function.<BR><BR>SELECT
 min(ST_Distance(l.the_geom,r.the_geom)) as Min_Width<BR>  FROM (select row_number() over (order by the_geom) as rin, the_geom<BR>          from River r<BR>          where r.Name = 'Barito' ) as l,<BR>        (select row_number() over (order by the_geom) as rin, the_geom<BR>          from River r<BR>          where r.Name = 'Barito' ) as r<BR>  WHERE l.rin = 1<BR>    AND r.rin = 2;<BR><BR>min_width<BR>double precision<BR>48.2597140480546<BR><BR>Hope this helps.<BR><BR>regards<BR>Simon<BR>On Wed, 14 Oct 2009 13:37:08 +1100, Surya Tarigan <<A href="mailto:surya.tarigan@yahoo.com" ymailto="mailto:surya.tarigan@yahoo.com">surya.tarigan@yahoo.com</A>> wrote:<BR><BR>> Dear List,<BR>><BR>> I have polyline depicting river banks. I have queried the minimum distance between left and right river bank as
 follows:<BR>><BR>> SELECT min(ST_Distance(r.the_geom, r.the_geom)) as Min_Width<BR>> FROM River as r<BR>> WHERE r.Name = 'Barito';<BR>><BR>> It returns zero ('0') result. The left and the right river bank have the same attributes (ID, Name, etc), that is why I use ST_Distance(r.the_geom, r.the_geom). Should I give different ID or Name for left and river bank. How the argument of ST_distance should look like.. The argument that I use above must be not correct (i.e. ST_Distance(r.the_geom, r.the_geom)).<BR>><BR>> Any clue would be appreciated<BR>><BR>> surya<BR>><BR>><BR>><BR>><BR>> ________________________________<BR>> From: Kevin Neufeld <<A href="mailto:kneufeld@refractions.net" ymailto="mailto:kneufeld@refractions.net">kneufeld@refractions.net</A>><BR>> To: PostGIS Users Discussion <<A href="mailto:postgis-users@postgis.refractions.net"
 ymailto="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</A>><BR>> Sent: Fri, October 2, 2009 12:35:17 PM<BR>> Subject: Re: [postgis-users] polygon minimum width<BR>><BR>> The linestrings wouldn't need to be continuous as long as you attribute them left and right bank.  Then your query would be to find the shortest distance between two linear datasets (left and right banks).  A cross product query would help you here.  Or, ST_Collect your banks into two multilinestrings, one for left and one for right bank.  Then compute the distance between them.<BR>><BR>> But you are still going to have problems at the head and mouth of the river.  There, the left and right banks touch, so the minimum distance between the left side of the river and right side of the river is zero.<BR>> -- Kevin<BR>><BR>> Surya Tarigan wrote:<BR>>> Hallo Nicklas<BR>>> fortunately I
 have linestring version of the polygon, but it seems that the linestirings are not continuous. Does st_distance still apply? Or are there any postgis function to make the polyline continuous?<BR>>>  kind regards,<BR>>>------------------------------------------------------------------------<BR>>> *From:* "<A href="mailto:nicklas.aven@jordogskog.no" ymailto="mailto:nicklas.aven@jordogskog.no">nicklas.aven@jordogskog.no</A>" <<A href="mailto:nicklas.aven@jordogskog.no" ymailto="mailto:nicklas.aven@jordogskog.no">nicklas.aven@jordogskog.no</A>><BR>>> *To:* PostGIS Users Discussion <<A href="mailto:postgis-users@postgis.refractions.net" ymailto="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</A>><BR>>> *Sent:* Thursday, October 1, 2009 3:50:37 PM<BR>>> *Subject:* Re: [postgis-users] polygon minimum width<BR>>><BR>>> Hallo<BR>>>  I think the
 easiest way is to make a linestring of the polygon.boundary and then cut the line in the start and end so you get two more or less paralell lines.. Then you can use st_distance to find the shortest distance between them.<BR>>>  Hope that helps<BR>>> Nicklas<BR>>><BR>>> 2009-10-01 Surya Tarigan wrote:<BR>>><BR>>> ><BR>>> ><BR>>> Dear list,<BR>>> ><BR>>>  ><BR>>> I  have a river polygon with polygon length about 20 km.  How can I query the minimum width of  the river polygon. I tried to search previous threads, but I could not find any clue.<BR>>> ><BR>>>  ><BR>>> kind regards,<BR>>> ><BR>>>  ><BR>>> surya<BR>>><BR>>> ><BR>>><BR>>> ------------------------------------------------------------------------<BR>>><BR>>>
 _______________________________________________<BR>>> postgis-users mailing list<BR>>> <A href="mailto:postgis-users@postgis.refractions.net" ymailto="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</A><BR>>> http://postgis.refractions.net/mailman/listinfo/postgis-users<BR>>><BR>> _______________________________________________<BR>> postgis-users mailing list<BR>> <A href="mailto:postgis-users@postgis.refractions.net" ymailto="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>><BR>><BR>><BR>><BR><BR><BR>-- <BR>SpatialDB Advice and Design, Solutions Architecture and Programming,<BR>Oracle Database 10g Administrator Certified Associate; Oracle Database 10g SQL Certified
 Professional<BR>Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius Topology and Studio Specialist.<BR>39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.<BR>Website: <A href="http://www.spatialdbadvisor.com/" target=_blank>www.spatialdbadvisor.com</A><BR>  Email: <A href="mailto:simon@spatialdbadvisor.com" ymailto="mailto:simon@spatialdbadvisor.com">simon@spatialdbadvisor.com</A><BR>  Voice: +61 362 396397<BR>Mobile: +61 418 396391<BR>Skype: sggreener<BR>Longitude: 147.20515 (147° 12' 18" E)<BR>Latitude: -43.01530 (43° 00' 55" S)<BR>GeoHash: r22em9r98wg<BR>NAC:W80CK 7SWP3<BR>_______________________________________________<BR>postgis-users mailing list<BR><A href="mailto:postgis-users@postgis.refractions.net" ymailto="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></DIV></DIV></div><br>

      </body></html>