PostGIS ST_OffsetCurve fails for some lines

Publish date: 2024-05-17

Using PostgreSQL and PostGIS I get an error when using ST_OffsetCurve for some specific line geometries: "lwgeom_offsetcurve: noded geometry cannot be offset"

Example:

SELECT ST_OffsetCurve(ST_GeomFromText('LINESTRING(288249.918098328 5615135.51135102,288293.425429089 5615086.62800628,288231.885629119 5615155.77174104,288249.918098328 5615135.51135102)'), -5.6875)

This is a closed line and the last three points are on a straight line. PostGIS version is 3.0 on Windows.

Changing any coordinates or even just the offset value slightly removes this error. Is it possible to prevent the error without changing numeric values?

3

2 Answers

Update to PostGIS version 3.1 solved the issue.

1

maybe ST_MakeValid fix this problem https://postgis.net/docs/ST_MakeValid.html

And it is also better to pass srid as second parametr in ST_GeomFromText

SELECT ST_OffsetCurve(ST_MakeValid(ST_GeomFromText(...., your srid)), -5.6875) 
1

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobXBoY2mEdX6OqaasrJeewG6%2F02amn56jmsGkwdGvnGaekZ65tHnFqKlmq5%2Bism64yKecrA%3D%3D