Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

add_water

Add Water


Description

Adds a layer of water to a map.

Usage

add_water(hillshade, watermap, color = "imhof1")

Arguments

hillshade

A three-dimensional RGB array.

watermap

Matrix indicating whether water was detected at that point. 1 indicates water, 0 indicates no water.

color

Default 'imhof1'. The water fill color. A hexcode or recognized color string. Also includes built-in colors to match the palettes included in sphere_shade: ('imhof1','imhof2','imhof3','imhof4', 'desert', 'bw', and 'unicorn').

Examples

#Here we even out a portion of the volcano dataset to simulate water:
island_volcano = volcano
island_volcano[island_volcano < mean(island_volcano)] = mean(island_volcano)

#Setting a minimum area avoids classifying small flat areas as water:
island_volcano %>%
 sphere_shade(texture="imhof3") %>%
 add_water(detect_water(island_volcano, min_area = 400),color="imhof3") %>%
 plot_map()
 
#We'll do the same thing with the Monterey Bay dataset to fill in the ocean:

montbay_water = montereybay
montbay_water[montbay_water < 0] = 0

montereybay %>%
 sphere_shade(texture="imhof4") %>%
 add_water(detect_water(montbay_water),color="imhof4") %>%
 plot_map()

rayshader

Create Maps and Visualize Data in 2D and 3D

v0.24.10
GPL-3
Authors
Tyler Morgan-Wall
Initial release
2021-04-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.