[postgis-users] Converting Multilinestrings to Linestrings

strk strk at keybit.net
Fri May 7 03:05:37 PDT 2010

On Fri, May 07, 2010 at 02:57:09AM -0700, Leigh Holcombe wrote:

> Is there a way to force linestring data to be imported as a linestring instead
> of as a multilinestring? 

Yes, shp2pgsql -S

> Is there a way to transform all the multilinestrings in a dataset into linestrings? 

1. Drop the type constraint (enforce_geotype_xxxx)
2. Update the geometries
3. Re-insert the type constraint
4. Update the geometry_columns record

> Is there a way to convert a multilinestring into a linestring easily and quickly
> on the fly (I'm doing PHP/LAPP programming)? 

ST_GeometryN(the_geom, 1) gives you the first LINESTRING of the (pseudo)set.


  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html

More information about the postgis-users mailing list