# NOT RUN {
#Plot the counties around Monterey Bay, CA
#Only run these examples if the `magick` package is installed.
if (length(find.package("magick", quiet = TRUE)) > 0) {
# }
# NOT RUN {
generate_polygon_overlay(monterey_counties_sf, palette = rainbow,
extent = attr(montereybay,"extent"), heightmap = montereybay) %>%
plot_map()
#These counties include the water, so we'll plot bathymetry data over the polygon
#data to only include parts of the polygon that fall on land.
water_palette = colorRampPalette(c("darkblue", "dodgerblue", "lightblue"))(200)
bathy_hs = height_shade(montereybay, texture = water_palette)
generate_polygon_overlay(monterey_counties_sf, palette = rainbow,
extent = attr(montereybay,"extent"), heightmap = montereybay) %>%
add_overlay(generate_altitude_overlay(bathy_hs, montereybay, start_transition = 0)) %>%
plot_map()
#Add a semi-transparent hillshade and change the palette, and remove the polygon lines
montereybay %>%
sphere_shade(texture = "bw") %>%
add_overlay(generate_polygon_overlay(monterey_counties_sf,
palette = terrain.colors, linewidth=NA,
extent = attr(montereybay,"extent"), heightmap = montereybay),
alphalayer=0.7) %>%
add_overlay(generate_altitude_overlay(bathy_hs, montereybay, start_transition = 0)) %>%
add_shadow(ray_shade(montereybay,zscale=50),0) %>%
plot_map()
#Map one of the variables in the sf object and use an explicitly defined color palette
county_palette = c("087" = "red", "053" = "blue", "081" = "green",
"069" = "yellow", "085" = "orange", "099" = "purple")
montereybay %>%
sphere_shade(texture = "bw") %>%
add_shadow(ray_shade(montereybay,zscale=50),0) %>%
add_overlay(generate_polygon_overlay(monterey_counties_sf, linecolor="white", linewidth=3,
palette = county_palette, data_column_fill = "COUNTYFP",
extent = attr(montereybay,"extent"), heightmap = montereybay),
alphalayer=0.7) %>%
add_overlay(generate_altitude_overlay(bathy_hs, montereybay, start_transition = 0)) %>%
add_shadow(ray_shade(montereybay,zscale=50),0.5) %>%
plot_map()
# }
# NOT RUN {
}
# }
Run the code above in your browser using DataLab