Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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:

ST_Intersection(way,st_geomfromtext('POLYGON(([etc]))',900913))

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
add comment

1 Answer

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.

http://postgis.net/docs/ST_Multi.html

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

Your Answer

 
discard

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.