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 two LINESTRING's which intersect by checking with st_intersects. Then i try to collect/union both linestrings into one Multistring, then try to merge with st_linemerge, but it fails with:

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

I check both geometries by using st_astext and get this:

LINESTRING(5.8836331 51.0196776,5.8841849 51.0190699,5.8843962 51.0188219,5.8849422 51.0182963)
LINESTRING(5.8841849 51.0190699,5.8840283 51.0190173,5.8839951 51.0189857,5.8839898 51.0189518,5.8840082 51.0189217,5.8840578 51.0188784,5.8841361 51.0188532,5.8842
492 51.0188324,5.8843962 51.0188219)

I see both have at least one point which intersects (be the same), so it should work. But when i try to merge them it fails or simply returns the multilinestring again.

Failing query:

gis=# select st_astext(
st_linemerge(
  st_collect(
    st_geomfromtext('LINESTRING(5.8836331 51.0196776,5.8841849 51.0190699,5.8843962 51.0188219,5.8849422 51.0182963)'),
    st_geomfromtext('LINESTRING(5.8841849 51.0190699,5.8840283 51.0190173,5.8839951 51.0189857,5.8839898 51.0189518,5.8840082 51.0189217,5.8840578 51.0188784,5.8841361 51.0188532,5.8842492 51.0188324,5.8843962 51.0188219)')
  )
));

 RESULT:
 MULTILINESTRING((5.8836331 51.0196776,5.8841849 51.0190699,5.8843962 51.0188219,5.8849422 51.0182963),(5.8841849 51.0190699,5.8840283 51.0190173,5.8839951 51.018985
7,5.8839898 51.0189518,5.8840082 51.0189217,5.8840578 51.0188784,5.8841361 51.0188532,5.8842492 51.0188324,5.8843962 51.0188219))
(1 row)

What is wrong here?

share|improve this question

1 Answer 1

Those linestrings cannot be resolevd to a new merged linestring. That is because the last point of the second line is the same as the second last point of the first line.

Not the last or the first.

What do you expect to happen to the last point:

5.8849422 51.0182963

...if it should be merged to one line:

share|improve this answer

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.