tylermorganwall / rayshader

R Package for 2D and 3D mapping and data visualization

Home Page:https://www.rayshader.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weird times - doing something wrong?

StyXman opened this issue · comments

Using one 1x1˚, 3600x3600px SRTM DEM and the following pieces of code, I get times I can't explain:

>     start_time <- Sys.time()
>     elmat %>%
+       sphere_shade(texture = "bw", progbar=TRUE) %>%
+       add_shadow(ambient_shade(elmat, multicore=TRUE, progbar=TRUE), 0) %>%
+     save_png('N45E006-shade-ambient_shade.png')
>     end_time <- Sys.time()                                                  
>     end_time - start_time
Time difference of 2.410213 mins

>     start_time <- Sys.time()
>     elmat %>%
+       ambient_shade(elmat, multicore=TRUE, progbar=TRUE) %>%
+       save_png('N45E006-ambient_shade.png')
>     end_time <- Sys.time()
>     end_time - start_time
Time difference of 6.674044 mins

Why does just calculating the ambient_shade() takes ~3x that doing sphere_shade() and then ambient_shade()?

You are passing in elmat twice in the second call (once in the pipe, and again in the function). Remove the second pipe and they should be equal.

>     start_time <- Sys.time()
>     elmat %>%
+       ambient_shade(multicore=TRUE, progbar=TRUE) %>%
+       save_png('N45E006-ambient_shade.png')
>     end_time <- Sys.time()
>     end_time - start_time

Oh silly me. :brown_paper_bag: Thanks for pointing it out