[postgis-users] Midd point for a segments

Kevin Neufeld kneufeld at refractions.net
Thu Jan 15 08:47:28 PST 2009


Since your multigeometry only contains a single linestring, use st_geometryn() to extract the linestring.

Putting your geometry in a temp table:
SELECT ST_X(mid_pt) AS long, ST_Y(mid_pt) AS lat
FROM (
   SELECT
     ST_Line_Interpolate_Point(
       ST_GeometryN(the_geom, 1), 0.5
     ) AS mid_pt
   FROM tmp_table
) AS foo;
        long       |       lat
------------------+------------------
  35.1719411367865 | 31.9319909231083
(1 row)


Cheers,
Kevin


Ahmad Bdair wrote:
> yes but ST_line_interpolate_point(linestring, location); returns the 
> geometry am I right? I tried it but it returned the half geometry, also 
> the function takes a linestring, I have multiline string, so I need to 
> convert multiline string to line string, I tried to use 
> lineMerge(the_geom) but didn't work.
> 
> On Tue, Jan 13, 2009 at 11:57 AM, Fred Lehodey <lehodey at gmail.com 
> <mailto:lehodey at gmail.com>> wrote:
> 
>     Hi,
>      
>     See ST_line_interpolate_point(linestring, location);
>     For mid-point : set 'location'= 0.5
>      
>     Fred
>      
> 
> 
>     On Tue, Jan 13, 2009 at 9:42 AM, bdair2002 <bdair2002 at gmail.com
>     <mailto:bdair2002 at gmail.com>> wrote:
> 
> 
>         Sorry for asking a lot of question lately, but If I have:
>         Segments A with those property:
>         Start point lonlat:35.1756965880001 31.930212709
>         End point: 35.1682984480001 31.9303062960001
>         the_geom :
>         0105000020E61000000100000001020000005B00000050BDCD397D964140907A8B6B22EE3F40107EC4177C964140E0F2FF5423EE3F40D0B7FA8E7A964140E0ED6DAC24EE3F40908DFE0C79964140A005D21926EE3F4090AA3F9277964140B09B919C27EE3F4070C23C1F76964140C0324E3429EE3F40D04136B474964140B04DA9E02AEE3F4098B6A85173964140001322A12CEE3F4080DEC0F669964140D0BF80DF38EE3F40A8B952925F964140902D621746EE3F4058A40B1C56964140104CE44550EE3F403836C8B24D964140D03A0EE95BEE3F4030FB725C49964140F01F3E2F63EE3F4050F08CA447964140C005535366EE3F40388C7ADC459641400055B25C69EE3F408819C30444964140A03D674A6CEE3F40081A10E742964140F0ACA8F16DEE3F406068D9C041964140302A66876FEE3F40C8EA74924096414090485F0B71EE3F401898565C3F964140C069F97C72EE3F40F845B61E3E964140401DABDB73EE3F40401919DA3C9641402007522775EE3F40F0B4DF8E3B9641405078355F76EE3F4080D95D3D3A964140A04F198377EE3F40A0A9977F3796414070469AAD79EE3F40B0D084B634964140101896AC7BEE3F4048B7CA252B96414020E6B70182EE3F40D01ACC911B964140D0925DC98BEE3F40009C80C116964140203999928EEE3F40589E5BE
311964140E0AB291291EE3F40A0D3E1F80C96414090C2404793EE3F4078AAA2030896414010CE253195EE3F4060BECB980496414010D31B4E96EE3F40102FEA2801964140C0313B3A97EE3F407089FDB4FD954140202EF6F497EE3F4070C3FC3DFA954140409A3B7E98EE3F40287FCBC4F6954140101AE9D598EE3F4018956D4AF3954140E09CE0FB98EE3F4018D2EF02F295414080828DF098EE3F40D01E13BCF0954140B04557CB98EE3F4048FB0177EF954140305A118698EE3F4090CF3634EE954140F0B8282798EE3F40681F25F5EC954140C0F6ACA897EE3F40E0F49E9FE9954140C0E5DC2D96EE3F4050DBB7AEE6954140A094390595EE3F40D0603EB9E39541408043970094EE3F409849CFBFE095414080AA3A2093EE3F403866BAF3DE95414060B7B7B192EE3F4080B4AA25DD95414010D8485E92EE3F4008AD3856DB954140A0FF182692EE3F40B8DDE085D995414090E2230992EE3F4018B9D34FD8954140905EDBEF91EE3F40608ABD1AD795414040375DBE91EE3F40D814BEE7D5954140C0E70E6F91EE3F40709ACC52D4954140F0F290DD90EE3F40F824A0C4D2954140B09F4C1D90EE3F4038DB0C3FD1954140009DFA2E8FEE3F40C8CE02C4CF954140D0BED8138EEE3F40A8FE31AFCE954140A01211248DEE3F4028334CAACC95414090AF53DF8BEE3F40A03B2
496C39541401078941586EE3F4008062690C2954140E0A54C5885EE3F4050D73B92C195414030EA637D84EE3F40C08BDA44C0954140708B972083EE3F40C8B9E541BF954140102EC7DF81EE3F40E08A501BBE954140E0D5E22880EE3F40F0596E3BBD954140108DCCA27EEE3F40806CD3F1BB954140E0E3F1337CEE3F40F80B39CDBA954140D0F00F307AEE3F4018E3649EB9954140F01DC33D78EE3F4018D8AC65B8954140A0AD835D76EE3F4040D16623B7954140B0F2E78F74EE3F40909F04D8B5954140A02293D572EE3F40989AE283B495414040CB012F71EE3F40108B6327B3954140F02EAC9C6FEE3F4010D901C3B1954140F026131F6EEE3F40D8011C57B09541402013A2B66CEE3F40783F1BE4AE9541405081D5636BEE3F40889B37E1AD954140B041F9716AEE3F40A0C79C92AC954140402E871069EE3F4038481352AB954140E048258B67EE3F40E87FD220AA954140508A96E365EE3F40D84A2700A995414020CA611B64EE3F40A0349732A8954140A09AF7B162EE3F4008D2F495A495414020B969FE5BEE3F408048F79498954140F00E684444EE3F40E85C3BD2929541402086421D39EE3F40480232B39095414050F75B2435EE3F4000BCBAA78E95414040CE210E31EE3F40E8DC6BB08C954140F04380DB2CEE3F406010B5CD8A9541405095AC8D28EE3F40
> 
>         It is mutiline String.
> 
>         Now, is there a direct way to find the Lonlat for middle point
>         of this
>         segment?
> 
>         Regards
> 
> 
>         --
>         View this message in context:
>         http://www.nabble.com/Midd-point-for-a-segments-tp21432225p21432225.html
>         Sent from the PostGIS - User mailing list archive at Nabble.com.
> 
>         _______________________________________________
>         postgis-users mailing list
>         postgis-users at postgis.refractions.net
>         <mailto:postgis-users at postgis.refractions.net>
>         http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> 
>     _______________________________________________
>     postgis-users mailing list
>     postgis-users at postgis.refractions.net
>     <mailto:postgis-users at postgis.refractions.net>
>     http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list