Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: line_merge with direction #2264

Closed
latot opened this issue Nov 14, 2023 · 1 comment
Closed

Feature Request: line_merge with direction #2264

latot opened this issue Nov 14, 2023 · 1 comment

Comments

@latot
Copy link

latot commented Nov 14, 2023

Hi all, actually there is the line_merge which works great, now for some cases we need to preserve the direction of the vectors, at least in the actual version there is no docs about it, so from that is not guarantee to keep the direction of the vectors.

Would be great have a new param on the function which we can select, if the join must preserve the direction of the vectors.

IIRC, preserve has two aspects:

  • End/Start points will be keep
  • Only joins vectors that keep the right direction, the wrong direction can cause to a vector to not be join
  • No idea what happens if there is 4 vectors, 2 in right direction, and other 2 in the right direction

Here some docs: https://postgis.net/docs/ST_LineMerge.html

IIRC geos has an option for that.

Thx!

@edzer edzer closed this as completed in ec14995 Nov 15, 2023
@edzer
Copy link
Member

edzer commented Nov 15, 2023

library(sf)
# Linking to GEOS 3.11.1, GDAL 3.6.4, PROJ 9.1.1; sf_use_s2() is TRUE

(x = st_multilinestring(list(rbind(c(0,0), c(1,0)), rbind(c(2,0), c(1,0)))))
# MULTILINESTRING ((0 0, 1 0), (2 0, 1 0))
st_line_merge(x)
# LINESTRING (0 0, 1 0, 2 0)
st_line_merge(x, directed = FALSE)
# LINESTRING (0 0, 1 0, 2 0)
st_line_merge(x, directed = TRUE)
# MULTILINESTRING ((0 0, 1 0), (2 0, 1 0))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants