[postgis-users] multiline to linestring

Dane Springmeyer blake at hailmail.net
Wed Feb 6 08:07:15 PST 2008


Gustavo,

I'm not exactly clear on how you want to use ST_Dump, but I'll give a  
shot a some example SQL that might help...

> I want to convert linestrings from multilinestrings, with  
> linemerge, to obtain united linestrings in overlapping points
> with this sentence:
>

In your subject you say "multiline to linestring" however.

 From the astext output below it seems you are saying that you  
started with multilinestrings and they didn't change after your  
query. Is that right?

>
> "MULTILINESTRING((4.8938679245283 46.3443396226415,33.313679245283  
> 73.7028301886792,49.5872641509434 80.0707547169811,90.9583136792453  
> 89.2813679245283,54.3363797169811 103.03608490566,29.0620872641509  
> 103.293985849057,12.2125589622641 107.1625,11.1624233831055  
> 106.590266209164,10.4214805264064 107.529010012923,11.2220067193803  
> 108.417488521584,12.2326314413493 107.778056025276), 
> (37.506947728971 97.6302534161404,12.1756482134062 82.9892270906306))"
>
> with numgeometries=2, the logic result with my original data.
> How can i extract those linestrings separately?
>

if you want to work with each multilinestring separately then I think  
you'll want to turn them into two linestrings in two rows.

This works for me:

--create that test data
create table ml_string (id serial,the_geom geometry);
insert into ml_string (the_geom) values (geomfromtext('MULTILINESTRING 
((4.8938679245283 46.3443396226415,33.313679245283  
73.7028301886792,49.5872641509434 80.0707547169811,90.9583136792453  
89.2813679245283,54.3363797169811 103.03608490566,29.0620872641509  
103.293985849057,12.2125589622641 107.1625,11.1624233831055  
106.590266209164,10.4214805264064 107.529010012923,11.2220067193803  
108.417488521584,12.2326314413493 107.778056025276),(37.506947728971  
97.6302534161404,12.1756482134062 82.9892270906306))',-1))

--check it as WKT
select astext(the_geom) from ml_string;

select g as id, ST_Dump(ST_GeometryN(the_geom,g)) from ml_string,  
generate_series(1,(Select ST_NumGeometries (the_geom) from  
ml_string)) as g;

--which is the nearly the same as directly calling ST_Dump on your  
multilinestring:
select ST_Dump(the_geom) from ml_string;


Sorry if I am off track. Just send another note with clarification if  
you can...

Dane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080206/607f1fae/attachment.html>


More information about the postgis-users mailing list