3

I'm trying to generate two line offsets from a line but I'm having problems generating them as they should be.

Using PostGIS

select st_asgeojson(st_union(the_geom)) from ( select ST_Line_Substring(ST_OffsetCurve(line_geom,0.00005),0,1) as the_geom from table_name where id = 7382 UNION select ST_Line_Substring(ST_OffsetCurve(line_geom,-0.00005),0,1) as the_geom from table_name where id = 7382 UNION select (line_geom) as the_geom from table_name where id = 7382) as a

the problem I'm seeing right now is the angle between the start/end of given line isn't perpendicular to the start/end of the other lines

Result: current result Expected: expected result

EDIT: lines' geometry and srid

"LINESTRING(-8.69371814905576 40.5676685897826,-8.69334901004008 40.567864446704)",4326 "LINESTRING(-8.6936947144568 40.5676244216994,-8.69332557544112 40.5678202786208)",4326 "LINESTRING(-8.69330214084216 40.5677761105376,-8.69367127985784 40.5675802536163)",4326

2
  • 1
    This could be a reprojection issue. I see your offset is very small so it it probably in degrees and that is not very suitable for this kind of operations. Can you add an ST_Text(line_geom) and ST_Srid(line_geom) output of your geometry to the question?
    – tilt
    Commented Oct 14, 2016 at 13:28
  • I found another way to accomplish what I wanted, the result is the same but I know for fact that it's now for sure a projection problem.
    – ColdFox
    Commented Oct 14, 2016 at 20:22

1 Answer 1

1

It was certainly a projection issue. You should first make sure you project your data into a local system. Here is what I used (for an offset of 2 meter in the portugese projection 3763):

WITH line AS (
SELECT 
ST_Transform(
    ST_SetSrid(
        ST_GeomFromText('LINESTRING(-8.6936947144568 40.5676244216994,-8.69332557544112 40.5678202786208)')
    ,4326) 
,3763)
geom
)
SELECT ST_OffsetCurve(geom,2) geom FROM line
UNION ALL
SELECT ST_OffsetCurve(geom,-2) geom FROM line
UNION ALL
SELECT geom FROM line;

I removed your LineSubstring since it didn't do anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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