Can I "turn off" arrows where the value is 0 in vectorplot? (no currents on land)

34 Views Asked by At

I am trying to make a map of Guam's current field using vectorplot in the rasterVis package. When I read in my original data where the currents on "land" were NA, I got errors so I am instead using a file where velocity on land is 0. But this means I get current vector arrows on land in my plot.

Is it possible to "tell" the plot not to plot vectors if the value =0? I am very new to rasterVis and grateful for any advice!

NetCDF file for current data can be found here: https://drive.google.com/drive/folders/12h9jN0rI6An8kF56ugNhODtVa40Z8vV0?usp=sharing[![enter image description here]1]1

ncfile_org <- 'guaROMS_2021Apr25May21_nan.nc' 

ucomp <- brick(ncfile_org, varname='u')
vcomp <- brick(ncfile_org, varname='v')

desired date to plot

d=181

ucomp1 <- ucomp[[d]]
vcomp1 <- vcomp[[d]]
ucomp1[is.na(ucomp1[])]=0
vcomp1[is.na(vcomp1[])]=0

uv=stack(ucomp1,vcomp1)

Plot Guam with current vectors. Note, I have changed the viridis palette so that "land" (velocity=0) is white.

vectorplot(uv,isField="dXY",region=TRUE, 
       par.setting=viridisTheme(region=c("#FFFFFFFF",viridis(10))))

Thank you so much for your help.

0

There are 0 best solutions below