Stephen Woodbridge | 7 Oct 22:52
Favicon

ST_UNION(linestring, linestring) returns a multilinestring

Hi all,

This is very annoying. I have two linestrings the join end-to-end and I 
want to build a new single linestring by merging the two. How can I do this?

Thanks,
   -Steve

select astext( 
ST_Union( 
         ST_GeomFromText('LINESTRING(35.5269251710001 
33.891749555,35.527091166 33.8917984710001)'),
ST_GeomFromText('LINESTRING(35.527091166 
33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 
33.8919810230001)')                                    ));

               astext 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  MULTILINESTRING((35.5269251710001 33.891749555,35.527091166 
33.8917984710001),(35.527091166 33.8917984710001,35.5274352000001 
33.8918998510001,35.528236559 33.8919810230001))
(1 row)
Favicon

Re: ST_UNION(linestring, linestring) returns a multilinestring

Check out ST_Merge()

On Tue, Oct 7, 2008 at 3:54 PM, Stephen Woodbridge <woodbri <at> swoodbridge.com> wrote:
Hi all,

This is very annoying. I have two linestrings the join end-to-end and I want to build a new single linestring by merging the two. How can I do this?

Thanks,
 -Steve


select astext( ST_Union(        ST_GeomFromText('LINESTRING(35.5269251710001 33.891749555,35.527091166 33.8917984710001)'),
ST_GeomFromText('LINESTRING(35.527091166 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 33.8919810230001)')                                    ));

             astext
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 MULTILINESTRING((35.5269251710001 33.891749555,35.527091166 33.8917984710001),(35.527091166 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 33.8919810230001))
(1 row)

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



--
************************************
David William Bitner
_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
Fred Lehodey | 7 Oct 22:23

Re: ST_UNION(linestring, linestring) returns a multilinestring

=>   ST_LineMerge()
Fred.
On Tue, Oct 7, 2008 at 8:58 PM, David William Bitner <bitner <at> gyttja.org> wrote:
Check out ST_Merge()


On Tue, Oct 7, 2008 at 3:54 PM, Stephen Woodbridge <woodbri <at> swoodbridge.com> wrote:
Hi all,

This is very annoying. I have two linestrings the join end-to-end and I want to build a new single linestring by merging the two. How can I do this?

Thanks,
 -Steve


select astext( ST_Union(        ST_GeomFromText('LINESTRING(35.5269251710001 33.891749555,35.527091166 33.8917984710001)'),
ST_GeomFromText('LINESTRING(35.527091166 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 33.8919810230001)')                                    ));

             astext
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 MULTILINESTRING((35.5269251710001 33.891749555,35.527091166 33.8917984710001),(35.527091166 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 33.8919810230001))
(1 row)

_______________________________________________
postgis-users mailing list
postgis-users <at> postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



--
************************************
David William Bitner

_______________________________________________
postgis-users mailing list
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
Stephen Woodbridge | 7 Oct 23:38
Favicon

Re: ST_UNION(linestring, linestring) returns a multilinestring

This does not seem to work. Am I using it wrong?

select astext(st_linemerge(b.the_geom))
   from (
     select ST_GeomFromText('LINESTRING(35.5269251710001 
33.891749555,35.527091166 33.8917984710001)') as the_geom
    union
    select ST_GeomFromText('LINESTRING(35.527091166 
33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 
33.8919810230001)') as the_geom
   ) as b;
                                                   astext 

-----------------------------------------------------------------------------------------------------------
  LINESTRING(35.5269251710001 33.891749555,35.527091166 33.8917984710001)
  LINESTRING(35.527091166 33.8917984710001,35.5274352000001 
33.8918998510001,35.528236559 33.8919810230001)
(2 rows)

The results that I am expecting to get are:

  LINESTRING(35.5269251710001 33.891749555,35.527091166 
33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 
33.8919810230001)

-Steve

Fred Lehodey wrote:
> =>   ST_LineMerge()
> Fred.
> On Tue, Oct 7, 2008 at 8:58 PM, David William Bitner <bitner <at> gyttja.org 
> <mailto:bitner <at> gyttja.org>> wrote:
> 
>     Check out ST_Merge()
> 
> 
>     On Tue, Oct 7, 2008 at 3:54 PM, Stephen Woodbridge
>     <woodbri <at> swoodbridge.com <mailto:woodbri <at> swoodbridge.com>> wrote:
> 
>         Hi all,
> 
>         This is very annoying. I have two linestrings the join
>         end-to-end and I want to build a new single linestring by
>         merging the two. How can I do this?
> 
>         Thanks,
>          -Steve
> 
> 
>         select astext( ST_Union(      
>          ST_GeomFromText('LINESTRING(35.5269251710001
>         33.891749555,35.527091166 33.8917984710001)'),
>         ST_GeomFromText('LINESTRING(35.527091166
>         33.8917984710001,35.5274352000001 33.8918998510001,35.528236559
>         33.8919810230001)')                                    ));
> 
>                      astext
>         --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>          MULTILINESTRING((35.5269251710001 33.891749555,35.527091166
>         33.8917984710001),(35.527091166
>         33.8917984710001,35.5274352000001 33.8918998510001,35.528236559
>         33.8919810230001))
>         (1 row)
> 
>         _______________________________________________
>         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
> 
> 
> 
> 
>     -- 
>     ************************************
>     David William Bitner
> 
>     _______________________________________________
>     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
Dane Springmeyer | 7 Oct 23:32
Favicon

Re: ST_UNION(linestring, linestring) returns a multilinestring

Stephen,

Try:

select astext(st_linemerge(ST_Collect(b.the_geom)))
  from (
    select ST_GeomFromText('LINESTRING(35.5269251710001  
33.891749555,35.527091166 33.8917984710001)') as the_geom
   union
   select ST_GeomFromText('LINESTRING(35.527091166  
33.8917984710001,35.5274352000001 33.8918998510001,35.528236559  
33.8919810230001)') as the_geom
  ) as b;

Thanks works for me.

Dane

On Oct 7, 2008, at 2:38 PM, Stephen Woodbridge wrote:

> This does not seem to work. Am I using it wrong?
>
>
> select astext(st_linemerge(b.the_geom))
>  from (
>    select ST_GeomFromText('LINESTRING(35.5269251710001  
> 33.891749555,35.527091166 33.8917984710001)') as the_geom
>   union
>   select ST_GeomFromText('LINESTRING(35.527091166  
> 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559  
> 33.8919810230001)') as the_geom
>  ) as b;
>                                                  astext
> -----------------------------------------------------------------------------------------------------------
> LINESTRING(35.5269251710001 33.891749555,35.527091166  
> 33.8917984710001)
> LINESTRING(35.527091166 33.8917984710001,35.5274352000001  
> 33.8918998510001,35.528236559 33.8919810230001)
> (2 rows)
>
> The results that I am expecting to get are:
>
> LINESTRING(35.5269251710001 33.891749555,35.527091166  
> 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559  
> 33.8919810230001)
>
> -Steve
>
>
> Fred Lehodey wrote:
>> =>   ST_LineMerge()
>> Fred.
>> On Tue, Oct 7, 2008 at 8:58 PM, David William Bitner <bitner <at> gyttja.org 
>>  <mailto:bitner <at> gyttja.org>> wrote:
>>    Check out ST_Merge()
>>    On Tue, Oct 7, 2008 at 3:54 PM, Stephen Woodbridge
>>    <woodbri <at> swoodbridge.com <mailto:woodbri <at> swoodbridge.com>> wrote:
>>        Hi all,
>>        This is very annoying. I have two linestrings the join
>>        end-to-end and I want to build a new single linestring by
>>        merging the two. How can I do this?
>>        Thanks,
>>         -Steve
>>        select  
>> astext 
>> ( ST_Union 
>> (               ST_GeomFromText('LINESTRING(35.5269251710001
>>        33.891749555,35.527091166 33.8917984710001)'),
>>        ST_GeomFromText('LINESTRING(35.527091166
>>        33.8917984710001,35.5274352000001  
>> 33.8918998510001,35.528236559
>>        33.8919810230001)')                                    ));
>>                     astext
>>         
>> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>         MULTILINESTRING((35.5269251710001 33.891749555,35.527091166
>>        33.8917984710001),(35.527091166
>>        33.8917984710001,35.5274352000001  
>> 33.8918998510001,35.528236559
>>        33.8919810230001))
>>        (1 row)
>>        _______________________________________________
>>        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
>>    --     ************************************
>>    David William Bitner
>>    _______________________________________________
>>    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
>
> _______________________________________________
> postgis-users mailing list
> postgis-users <at> postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
Stephen Woodbridge | 8 Oct 05:10
Favicon

Re: ST_UNION(linestring, linestring) returns a multilinestring

Dane,

Thanks, that worked great.

-Steve

Dane Springmeyer wrote:
> Stephen,
> 
> Try:
> 
> select astext(st_linemerge(ST_Collect(b.the_geom)))
>  from (
>    select ST_GeomFromText('LINESTRING(35.5269251710001 
> 33.891749555,35.527091166 33.8917984710001)') as the_geom
>   union
>   select ST_GeomFromText('LINESTRING(35.527091166 
> 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 
> 33.8919810230001)') as the_geom
>  ) as b;
> 
> Thanks works for me.
> 
> Dane
> 
> 
> On Oct 7, 2008, at 2:38 PM, Stephen Woodbridge wrote:
> 
>> This does not seem to work. Am I using it wrong?
>>
>>
>> select astext(st_linemerge(b.the_geom))
>>  from (
>>    select ST_GeomFromText('LINESTRING(35.5269251710001 
>> 33.891749555,35.527091166 33.8917984710001)') as the_geom
>>   union
>>   select ST_GeomFromText('LINESTRING(35.527091166 
>> 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 
>> 33.8919810230001)') as the_geom
>>  ) as b;
>>                                                  astext
>>
----------------------------------------------------------------------------------------------------------- 
>>
>> LINESTRING(35.5269251710001 33.891749555,35.527091166 33.8917984710001)
>> LINESTRING(35.527091166 33.8917984710001,35.5274352000001 
>> 33.8918998510001,35.528236559 33.8919810230001)
>> (2 rows)
>>
>> The results that I am expecting to get are:
>>
>> LINESTRING(35.5269251710001 33.891749555,35.527091166 
>> 33.8917984710001,35.5274352000001 33.8918998510001,35.528236559 
>> 33.8919810230001)
>>
>> -Steve
>>
>>
>> Fred Lehodey wrote:
>>> =>   ST_LineMerge()
>>> Fred.
>>> On Tue, Oct 7, 2008 at 8:58 PM, David William Bitner 
>>> <bitner <at> gyttja.org <mailto:bitner <at> gyttja.org>> wrote:
>>>    Check out ST_Merge()
>>>    On Tue, Oct 7, 2008 at 3:54 PM, Stephen Woodbridge
>>>    <woodbri <at> swoodbridge.com <mailto:woodbri <at> swoodbridge.com>> wrote:
>>>        Hi all,
>>>        This is very annoying. I have two linestrings the join
>>>        end-to-end and I want to build a new single linestring by
>>>        merging the two. How can I do this?
>>>        Thanks,
>>>         -Steve
>>>        select astext( ST_Union(               
>>> ST_GeomFromText('LINESTRING(35.5269251710001
>>>        33.891749555,35.527091166 33.8917984710001)'),
>>>        ST_GeomFromText('LINESTRING(35.527091166
>>>        33.8917984710001,35.5274352000001 33.8918998510001,35.528236559
>>>        33.8919810230001)')                                    ));
>>>                     astext
>>>        
>>>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
>>>
>>>         MULTILINESTRING((35.5269251710001 33.891749555,35.527091166
>>>        33.8917984710001),(35.527091166
>>>        33.8917984710001,35.5274352000001 33.8918998510001,35.528236559
>>>        33.8919810230001))
>>>        (1 row)
>>>        _______________________________________________
>>>        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
>>>    --     ************************************
>>>    David William Bitner
>>>    _______________________________________________
>>>    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
>>
>> _______________________________________________
>> postgis-users mailing list
>> 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

Gmane