3

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?

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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