Skip to content

21 function to get elevation associated with points - #80

Merged
Robinlovelace merged 4 commits into
masterfrom
21-function-to-get-elevation-associated-with-points
Jun 22, 2026
Merged

Robinlovelace merged 4 commits into
masterfrom
21-function-to-get-elevation-associated-with-points

Conversation

@temospena

Copy link
Copy Markdown
Collaborator

1. Added Support for POINT Geometries (Closes #21)

  • Extended elevation_add() to gracefully handle sf objects containing POINT or MULTIPOINT geometries.
  • Consistent API: By default (add_z = TRUE), the function embeds the extracted elevation directly into the point's geometry as the Z coordinate (returning POINT Z features), mirroring the behavior for linestrings.
  • Flexibility: Added an add_column = TRUE/FALSE parameter for points, allowing users to optionally append the elevation as an explicit data frame attribute column. Setting add_z = FALSE and add_column = TRUE allows returning a standard XY geometry with the elevation only in the column.

2. Reorganized Scripts & Separated Concerns

  • Created a new centralized R/elevation.R file to handle all elevation-related operations (elevation_extract, elevation_add, elevation_get, and sf_mid_ext_lonlat).
  • Moved all z_* helper functions from R/z-functions.R into R/elevation.R and deleted the orphaned file.
  • R/slopes.R is now strictly dedicated to pure slope mathematical estimations.
  • R/slope_get.R is now strictly dedicated to raster/matrix utility functions.

3. Test Suite Refactoring & Coverage

  • Created a new tests/testthat/test-elevation.R file and migrated all elevation/Z-coordinate tests over from test-slopes.R, test-get.R, and test-z.R (deleting the latter two).
  • Added comprehensive unit tests for elevation_add() with point geometries, covering all permutations of the add_z and add_column arguments.

4. Documentation Updates

  • Updated the roxygen documentation for elevation_add() to explicitly detail the behavior with points and the new add_column and add_z parameters.
  • Added explicit @examples for point geometries directly in the documentation.
  • Updated the "Get started" vignette to mention that elevation_add() also works natively with points.

@temospena temospena linked an issue Jun 22, 2026 that may be closed by this pull request
@temospena
temospena requested a review from Robinlovelace June 22, 2026 13:04
@Robinlovelace
Robinlovelace merged commit 98d271e into master Jun 22, 2026
4 checks passed
@Robinlovelace
Robinlovelace deleted the 21-function-to-get-elevation-associated-with-points branch June 22, 2026 19:56
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.

Function to get elevation associated with points

2 participants