Skip to content

66 working with segments vignette - #76

Merged
temospena merged 3 commits into
masterfrom
66-working-with-segments---vignette
Jun 16, 2026
Merged

temospena merged 3 commits into
masterfrom
66-working-with-segments---vignette

Conversation

@temospena

Copy link
Copy Markdown
Collaborator

Fixed: m[, "L1"] — uses the named column, which correctly holds the feature row index.

The vignette now has two subsections under "Working with segments":

  • By vertex — route_to_segments(), one segment per coordinate pair → finer resolution, follows the exact linestring geometry
  • By fixed length — stplanr::line_segment(100), then elevation_add() → coarser, user-controlled granularity

@temospena temospena linked an issue Jun 16, 2026 that may be closed by this pull request
@temospena
temospena requested a review from Robinlovelace June 16, 2026 17:27
Comment thread vignettes/slopes.Rmd
# Load example data
data(lisbon_route)
dem_lisbon = dem_lisbon()
dem_lisbon <- dem_lisbon()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these operator changes are annoying. please ignore.

Comment thread R/slopes.R
}
n <- nrow(routes)
linestrings <- lapply(seq(n), function(i) sf::st_linestring(m_xyz[m[, 3] == i, ]))
linestrings <- lapply(seq(n), function(i) sf::st_linestring(m_xyz[m[, "L1"] == i, ]))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be more specific and clear, seeing as we want a vector output?

Suggested change
linestrings <- lapply(seq(n), function(i) sf::st_linestring(m_xyz[m[, "L1"] == i, ]))
linestrings <- lapply(seq(n), function(i) sf::st_linestring(m_xyz[m[["L1"]] == i, ]))

Not tested but imagine it should work..

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, for a data.frame. but this is a matrix (from st_coordinates()), right? not sure if works the same way...

@temospena
temospena merged commit 2d14930 into master Jun 16, 2026
4 checks passed
@temospena
temospena deleted the 66-working-with-segments---vignette branch June 16, 2026 18:30
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

Successfully merging this pull request may close these issues.

Working with segments - vignette

2 participants