0

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.

Heidi
  • 11
  • 1
  • Can you please try to create a minimal reproducible example? This should be easy enough given the problem – Robert Wilson Aug 29 '22 at 06:27
  • Hi @Robert, I'm not sure I know how to do that for the relevant spatial data since my problem is in removing vectors where there is land. I wanted to provide the actual spatial (current) data in case the solution is to treat the data differently upstream from vectorplot versus removing select vectors in the plot (or blocking plotting of the zero vectors). – Heidi Aug 29 '22 at 19:20

0 Answers0