Skip to content

Commit

Permalink
rayshader v0.38.5: Fix render_points() interpolation when nearest n…
Browse files Browse the repository at this point in the history
…eighbor is NA in DEM
  • Loading branch information
tylermorganwall committed Dec 23, 2024
1 parent 891e57f commit 368457a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 982 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: rayshader
Type: Package
Title: Create Maps and Visualize Data in 2D and 3D
Version: 0.38.4
Date: 2024-12-13
Version: 0.38.5
Date: 2024-12-22
Authors@R:
person("Tyler", "Morgan-Wall", email = "[email protected]",role = c("aut", "cph", "cre"),
comment = c(ORCID = "0000-0002-3131-3814"))
Expand Down Expand Up @@ -55,4 +55,4 @@ URL: https://www.rayshader.com,
https://github.com/tylermorganwall/rayshader
BugReports: https://github.com/tylermorganwall/rayshader/issues
Config/testthat/edition: 3
Remotes: tylermorganwall/raybevel, tylermorganwall/rayimage, tylermorganwall/rayrender
Remotes: tylermorganwall/raybevel, tylermorganwall/rayimage, tylermorganwall/rayrender
4 changes: 3 additions & 1 deletion R/render_points.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#'
#'@description Adds 3D datapoints to the current scene, using latitude/longitude or coordinates in the reference
#'system defined by the extent object. If no altitude is provided, the points will be elevated a constant offset
#'above the heightmap. If the points goes off the edge, the nearest height on the heightmap will be used.
#'above the heightmap. If the points goes off the edge, the nearest height on the heightmap will be used (unless that
#'value is NA, in which the point will be removed).
#'
#'@param lat Vector of latitudes (or other coordinate in the same coordinate reference system as extent).
#'@param long Vector of longitudes (or other coordinate in the same coordinate reference system as extent).
Expand Down Expand Up @@ -111,6 +112,7 @@ render_points = function(lat = NULL, long = NULL, altitude = NULL, extent = NULL
}
xyz = transform_into_heightmap_coords(extent, heightmap, lat, long,
altitude, offset, zscale)

if(length(size) > 1) {
stopifnot(length(size) == nrow(xyz))
color_length = length(color)
Expand Down
6 changes: 4 additions & 2 deletions R/transform_into_heightmap_coords.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ transform_into_heightmap_coords = function(extent, heightmap, lat = NULL, long =
}
altitude[filter_out] = NA
if(use_altitude) {
return(matrix(c(distances_x-nrow_map/2-1, altitude/zscale + offset, distances_y-ncol_map/2-1),ncol=3,nrow=length(altitude)))
matrix_vals = (matrix(c(distances_x-nrow_map/2-1, altitude/zscale + offset, distances_y-ncol_map/2-1),ncol=3,nrow=length(altitude)))
} else {
return(matrix(c(distances_x-nrow_map/2-1, offset, distances_y-ncol_map/2-1),ncol=3,nrow=length(altitude)))
matrix_vals = (matrix(c(distances_x-nrow_map/2-1, offset, distances_y-ncol_map/2-1),ncol=3,nrow=length(altitude)))
}
final_vals = matrix_vals[!is.na(matrix_vals[,2]),]
return(final_vals)
}
3 changes: 2 additions & 1 deletion man/render_points.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/plot_3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"material_hashes": {
"type": "character",
"attributes": {},
"value": ["85572a9eb434039e855c5c201767954f", "644c1a1c2ed4558cdd2145be2555adab", "3b2d8f9173e160ae19225b682daa1cc4"]
"value": ["254214f7e8d43b757f870268c8405e24", "644c1a1c2ed4558cdd2145be2555adab", "303a9d1de8704c45014b7b3b60907145"]
}
},
"value": [
Expand Down
974 changes: 0 additions & 974 deletions tests/testthat/_snaps/plot_3d.new.md

This file was deleted.

0 comments on commit 368457a

Please sign in to comment.