# Can LINESTRING "contain" POINT?

According to Wikipedia,

The predicates `Contains` and `Within` have subtle aspects to their definition which are contrary to intuition. For example,[10] a line L which is completely contained in the boundary of a polygon P is not considered to be contained in P. This quirk can be expressed as "Polygons do not contain their boundary". This issue is caused by the final clause of the Contains definition above: "at least one point of the interior of B lies in the interior of A". For this case, the predicate Covers has more intuitive semantics (see definition), avoiding boundary considerations.

If Polygons do not Contain their boundaries, do linestrings ever "contain" points?

At least according to PostGIS, a LINESTRING does `CONTAIN` the constituent point along the string, but it does not `CONTAIN` the terminal points,

``````-- false
SELECT ST_Contains(
ST_MakeLine(ST_MakePoint(0,0), ST_MakePoint(1,1)),
ST_MakePoint(1,1)
);

-- true
SELECT ST_Contains(
ST_MakeLine(ST_MakePoint(0,0), ST_MakePoint(1,1)),
ST_MakePoint(0.5,0.5)
);
``````

While `ST_Intersects` will return true for both.

• If you have a multipoint, with one point on the line and the other at the extremity, the line would contains the multipoint... but not if both are on the extremities (nor if one is clearly outside of the line)
– JGH
Sep 5, 2018 at 17:56
• just adding: terminal points are considered to be the boundary of a line, and contains requires at least one point of the interior to intersect the interior of the other - not given for a point on the lines boundary. I used the DE-9IM a lot, out of personal interest and for ultimate control of what relation is to be checked...its a little intense, each time again if not fully concentrated, but it's worth to give it a good read. all relation functions are, of course, only wrappers around this model, and the relation concepts are mostly standardized, e.g. the way contains is interpreted. Sep 5, 2018 at 20:17
• the interior of a geometry is always of the expected dimension, the boundary of one lesser. except for points, where both predicates fall on the same entity...thus, a point can contain a point... Sep 5, 2018 at 20:28
• no, pardon me, I think that might even be true for points, where per definition there is a null-dimensional border...when I got the time, I'll back all this up with references and add an informative answer. hope I find that time... Sep 5, 2018 at 20:54
• `SELECT ST_Contains( ST_MakePoint(0,0), ST_MakePoint(0,0) );` returns true. Sep 5, 2018 at 20:57