4

I'm creating a map in r using the mapview package. I have a raster layer with a vector layer displayed over it. I want to view the raster data completely. How do you set vector data to be completely transparent (i.e. just an outline)?

A reproducible example from their vignette:

m1 <- mapView(franconia, col.regions = "red")
m2 <- mapView(breweries)
### add two mapview objects
m1 + m2
'+'(m2, m1)
### add layers to a mapview object
if (interactive()) {
library(plainview)
m1 + breweries + plainview::poppendorf[[4]]
}

In this example, I would want breweries to be completely transparent. However changing col.regions = 'transparent' for breweries isn't what I'm looking for. It's still opaque as seen when clicking on the zoom button (plainview::poppendorf[[4]]) on the lower right hand side. enter image description here

1 Answer 1

8

alpha.regions parameter is the answer:

m1 <- mapview::mapview(ndvi_cropped_20181005, map.types = 'OpenStreetMap')
m2 <- mapview::mapview(fallowed_reprojected, color = 'cyan', alpha.regions = 0)
m1 + m2

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.