different results for ST_Relate with 3 parameters compared to those for ST_Relate with 2 parameters

Antonio Valanzano anvalanz at gmail.com
Wed Oct 15 13:29:20 PDT 2025


Dear Paul
here are the results with the new linestrings as you suggested

SELECT
  d.id,
  ST_Relate(d.geom, l.geom) as patternMatrix
FROM docks as d, lakes as l
WHERE ST_Relate(d.geom, l.geom, '1FF00F212') = true;
-- 1 row

"id" "patternmatrix"
7 "1FF00F212"

SELECT
  d.id,
  ST_Relate(d.geom, l.geom) as patternMatrix
FROM docks as d, lakes as l
WHERE ST_Relate(d.geom, l.geom) = '1FF00F212';
-- 4 rows
"id" "patternmatrix"
7 "1FF00F212"
8 "1FF00F212"
12 "1FF00F212"
13 "1FF00F212"

As you can see nothing has changed.

I was wondering which version of PostGIS (and on which platform)  has been
used for producing the material reported into the tutorial (which shows 2
rows as a correct result).

I understand that it is difficult to find the reason for different results
on different platforms but this shouldn't happen otherwise users are
confused.. and not sure about the correct results.

When in the near future I will upgrade to PostgreSQL 18  and PostGIS 3.6.0
I will try again the same two queries  and let you know if the results will
be the same or not.
Thanks for the time you have spent on this matter.

Antonio


Il giorno mer 15 ott 2025 alle ore 22:03 Paul Ramsey <
pramsey at cleverelephant.ca> ha scritto:

>
>
> On Wed, Oct 15, 2025 at 12:53 PM Antonio Valanzano <anvalanz at gmail.com>
> wrote:
>
>> Hi Paul
>> I have upgraded to PosGIS 3.5.3 and GEOS  3.13.1 as you can see from the
>> following output
>>
>> "postgis_full_version"
>> "POSTGIS=""3.5.3 3.5.3"" [EXTENSION] PGSQL=""170""
>> GEOS=""3.13.1-CAPI-1.19.2"" PROJ=""8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=
>> https://cdn.proj.org
>> USER_WRITABLE_DIRECTORY=C:\Windows\ServiceProfiles\NetworkService\AppData\Local/proj
>> DATABASE_PATH=C:\Program
>> Files\PostgreSQL\17\share\contrib\postgis-3.5\proj\proj.db"" (compiled
>> against PROJ 8.2.1) LIBXML=""2.12.5"" LIBJSON=""0.12""
>> LIBPROTOBUF=""1.2.1"" WAGYU=""0.5.0 (Internal)"" (core procs from ""3.5.2
>> 3.5.2"" need upgrade)"
>>
>> but the results are the same with one row for a query and 2 rows for the
>> other query.
>>
>> Is this a known bug or no other user has already reported this behaviour ?
>>
>
> Not reported, and I'm afraid not solvable unless you can figure out the
> specific thing about your install vs mine that is giving you a different
> answer. (Windows is one possibility, though not one I particularly like,
> platform differences are incredibly hard to isolate.)
>
> Seeing if the problem is ordering based and number of entries based might
> be interesting.
>
> DELETE FROM docsk;
> INSERT INTO docks ( geom, good )
>   VALUES
>         ('LINESTRING (170 290, 205 272)',true),
>         ('LINESTRING (120 215, 176 197)',true),
>         ('LINESTRING (290 260, 340 250)',false),
>         ('LINESTRING (350 300, 400 320)',false),
>         ('LINESTRING (370 230, 420 240)',false),
>         ('LINESTRING (170 290, 205 272)',true),
>         ('LINESTRING (120 215, 176 197)',true),
>         ('LINESTRING (370 180, 390 160)',false);
>
> P
>
>
>> Antonio
>>
>>
>>
>>
>> Il giorno mer 15 ott 2025 alle ore 20:59 Paul Ramsey <
>> pramsey at cleverelephant.ca> ha scritto:
>>
>>> Sorry, I still cannot replicate. My 3.5 build still returns both
>>> results. Maybe update to PostGIS 3.5.4 and GEOS 3.13.1 ?
>>> P.
>>>
>>> On Wed, Oct 15, 2025 at 11:25 AM Antonio Valanzano <anvalanz at gmail.com>
>>> wrote:
>>>
>>>> Here is the details of my installation:
>>>>
>>>> "postgis_full_version"
>>>> "POSTGIS=""3.5.2 3.5.2"" [EXTENSION] PGSQL=""170""
>>>> GEOS=""3.13.0-CAPI-1.19.0"" PROJ=""8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=
>>>> https://cdn.proj.org
>>>> USER_WRITABLE_DIRECTORY=C:\Windows\ServiceProfiles\NetworkService\AppData\Local/proj
>>>> DATABASE_PATH=C:\Program
>>>> Files\PostgreSQL\17\share\contrib\postgis-3.5\proj\proj.db"" (compiled
>>>> against PROJ 8.2.1) LIBXML=""2.12.5"" LIBJSON=""0.12""
>>>> LIBPROTOBUF=""1.2.1"" WAGYU=""0.5.0 (Internal)"""
>>>>
>>>> Antonio
>>>>
>>>>
>>>>
>>>> Il giorno mer 15 ott 2025 alle ore 19:28 Paul Ramsey <
>>>> pramsey at cleverelephant.ca> ha scritto:
>>>>
>>>>> Maybe you have found an old bug? Running exactly the same SQL as you,
>>>>> I get two rows from each query.
>>>>>
>>>>> postgis=# SELECT
>>>>>
>>>>>                 d.id,
>>>>>
>>>>>                                ST_Relate(d.geom, l.geom) as patternMatrix
>>>>>
>>>>>                                       FROM docks as d, lakes as l
>>>>>
>>>>>                                                WHERE ST_Relate(d.geom,
>>>>> l.geom, '1FF00F212');
>>>>>  id | patternmatrix
>>>>> ----+---------------
>>>>>   1 | 1FF00F212
>>>>>   2 | 1FF00F212
>>>>> (2 rows)
>>>>>
>>>>> postgis=# SELECT
>>>>> postgis-#   d.id,
>>>>> postgis-#   ST_Relate(d.geom, l.geom) as patternMatrix
>>>>> postgis-# FROM docks as d, lakes as l
>>>>> postgis-# WHERE ST_Relate(d.geom, l.geom) = '1FF00F212';
>>>>>  id | patternmatrix
>>>>> ----+---------------
>>>>>   1 | 1FF00F212
>>>>>   2 | 1FF00F212
>>>>> (2 rows)
>>>>>
>>>>> postgis=#
>>>>> postgis=# select postgis_full_version();
>>>>>
>>>>>
>>>>>
>>>>>     postgis_full_version
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>>>>  POSTGIS="3.7.0dev 3.6.0rc2-134-g5dc95f1bc" [EXTENSION] PGSQL="180"
>>>>> GEOS="3.15.0dev-CAPI-1.21.0" PROJ="9.6.2 NETWORK_ENABLED=ON URL_ENDPOINT=
>>>>> https://cdn.proj.org
>>>>> USER_WRITABLE_DIRECTORY=/Users/pramsey/Library/Application Support/proj
>>>>> DATABASE_PATH=/opt/homebrew/Cellar/proj/9.6.2/share/proj/proj.db" (compiled
>>>>> against PROJ 9.6.2) LIBXML="2.9.13" LIBJSON="0.18" LIBPROTOBUF="1.5.2"
>>>>> WAGYU="0.5.0 (Internal)" (core procs from "3.7.0dev
>>>>> 3.6.0rc2-125-g747d7732b" need upgrade)
>>>>>
>>>>> On Wed, Oct 15, 2025 at 9:22 AM Antonio Valanzano <anvalanz at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> I am following the "Introduction to PostGIS " tutorial  at
>>>>>> https://postgis.net/workshops/postgis-intro/
>>>>>> and for chapter 26 "Dimensionally Extended 9-Intersection Model"  I
>>>>>> am trying to replicate the examples.
>>>>>>
>>>>>> If I use the two different versions of ST_Relate I do not obtain the
>>>>>> same result
>>>>>>
>>>>>> SELECT
>>>>>>   d.id,
>>>>>>   ST_Relate(d.geom, l.geom) as patternMatrix
>>>>>> FROM docks as d, lakes as l
>>>>>> WHERE ST_Relate(d.geom, l.geom, '1FF00F212') = true;
>>>>>> -- 1 row
>>>>>> "id" "patternmatrix"
>>>>>> 1    "1FF00F212"
>>>>>>
>>>>>>
>>>>>>
>>>>>> SELECT
>>>>>>   d.id,
>>>>>>   ST_Relate(d.geom, l.geom) as patternMatrix
>>>>>> FROM docks as d, lakes as l
>>>>>> WHERE ST_Relate(d.geom, l.geom) = '1FF00F212';
>>>>>> -- 2 rows
>>>>>> "id" "patternmatrix"
>>>>>> 1    "1FF00F212"
>>>>>> 2    "1FF00F212"
>>>>>>
>>>>>> Could someone give me an explanation of such a difference ?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20251015/7fb85d7d/attachment.htm>


More information about the postgis-users mailing list