tylermorganwall / rayshader

R Package for 2D and 3D mapping and data visualization
https://www.rayshader.com/
2.06k stars 214 forks source link

Feature request: Remove water from STL #72

Closed MattNewberry closed 5 years ago

MattNewberry commented 5 years ago

I'm using the tool to generate models for use on my CNC router, and would love to be able to isolate water from land to be able to carve it completely out. I'm able to generate models for my area, and water detection is working, however I'd like to be able to use the water detection to cut away the STL shape model. Thank you for the awesome work!

tylermorganwall commented 5 years ago

You can do this pretty easily already--check out this gist where I use the detect_water() feature to carve the water out of the topography:

https://gist.github.com/tylermorganwall/ce755fdf6bafd00fe6d68ca445780b52

The key is just setting the areas where water is detected to NA (and flipping the matrix around to align with the original map)

elmat_no_water[rayshader:::fliplr(detect_water(elmat)) == 1] = NA
elmat_no_water %>%
  sphere_shade() %>%
  plot_3d(elmat_no_water)
tylermorganwall commented 5 years ago

This was used to generate the animation in this tweet:

https://twitter.com/tylermorganwall/status/1166338131257438210