Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a table of linestrings (OSM roads, in fact) that I'm displaying on a map. I want to filter them so that only those within a certain area are displayed- I've already done this with the coastline (a table of polygons) with great success, just using ST_Intersection. However, that doesn't appear to work on the linestrings. When I try something like this:


I get the following:

Error : ERROR:  Geometry type (MultiLineString) does not match column type (LineString)

Presumably the ST_Intersection is returning multiple lines rather than the single one I am expecting- but not all do, because if I change the column to be MultiLineString then it complains that it can't insert a LineString.

How can I ensure that these MultiLineStrings and Linestrings are the same type, and can all be inserted together?

share|improve this question
up vote 3 down vote accepted

If you just need to make sure a MULTILINESTRING is returned, use ST_Multi:

ST_Multi — Returns the geometry as a MULTI* geometry. If the geometry is already a MULTI*, it is returned unchanged.

share|improve this answer
That worked perfectly, thanks! – Alastair Feb 1 '13 at 14:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.