<div dir="ltr">Dear Sir/Ma'am,<div> I am Facing an error while masking the data with the shapefile.<div>Please guide me and resolve my problem.</div><div><br></div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div><div><br>  ;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br><br>  load "./shapefile_utils.ncl"<br>  load "./mask_data_with_gadm_country.ncl"<br><br>  diri   = "./"<br>  fili   = "<a href="http://IMD_2000_2010_daily_rf_0.25_ncl_monsum.nc" target="_blank">IMD_2000_2010_daily_rf_0.25_ncl_monsum.nc</a>"<br>  <br>  <br>  <br>  f      = addfile(diri+fili, "r")<br><br>  prc    = flt2dble(f->rf)<br>  pmsg   = prc@_FillValue      ; convenience<br><br>  printVarSummary(prc)<br>  printMinMax(prc,0)<br><br>  runlen = (/ 12 /)   <br>  nrun   = dimsizes(runlen)<br>;*********************************<br>; plot parameters<br>;*********************************<br>  dimprc = dimsizes(prc)<br>  ntim   = dimprc(0)<br>  nlat   = dimprc(1)<br>  mlon   = dimprc(2)<br>  <br>  <br>  yyyymm = f->time<br>  yyyymm = yyyymm/100<br>  year    = yyyymm/100<br>  yrStrt  = toint(year(0))<br>  yrLast  = toint(year(ntim-1))<br>  nyear   = yrLast-yrStrt+1<br>  yyyymm  = yyyymm_time(yrStrt, yrLast, "integer")<br>  yrfrac  =  (/yyyymm_to_yyyyfrac(yyyymm, 0.0)/)<br>  prc&time = (/yyyymm/)<br><br><br>;=================================<br>wks_type = "png"<br>   wks_type@wkWidth = 2500      ; for resolution<br>   wks_type@wkHeight = 2500<br>  wks          = gsn_open_wks ("png","spi_mask") ; send graphics to PNG file<br>  cmap = read_colormap_file("BlueWhiteOrangeRed")  ; read color data<br><br>  res                      = True                   <br>  res@gsnDraw              = False              ; don't draw<br>  res@gsnFrame             = False              ; don't advance frame<br>  res@gsnAddCyclic         = False               <br>  res@cnFillOn             = True               ; color fill<br>  res@cnFillPalette        = cmap(::-1,:)       ; set and reverse color map <br>  res@cnFillMode           = "RasterFill"       ; Raster Mode<br>  res@cnLinesOn            =  False             ; Turn off contour lines<br>  res@cnLevelSelectionMode = "ManualLevels"     ; set manual contour levels<br>  res@cnMinLevelValF       = -3.0               ; set min contour level<br>  res@cnMaxLevelValF       =  3.0               ; set max contour level<br>  res@cnLevelSpacingF      =  0.5               ; set contour spacing<br>  res@lbLabelBarOn         = False              ; turn off individual cb's<br>  res@txFont               = "courier-bold"     ; bold text<br>  res@mpFillOn             = False              ; backgroung map <br><br>  resP                      = True                   ; panel resources<br> ;resP@gsnPanelMainString  = "SPI: 1980-2019 (IMD)"  ; add center string<br>  resP@gsnPanelLabelBar     = True                   ; add common colorbar<br> <br>  res@mpMinLatF             =  7.5         ; India limits<br>  res@mpMaxLatF             =  37.5<br>  res@mpMinLonF             =  68<br>  res@mpMaxLonF             =  97.5<br>  <br><br>  <br>   diri   = "./"<br> shp  = "BGD_adm1.shp"<br> <br> s      = addfile(diri+shp, "r")<br><br> slat      = s->y<br> slon      = s->x<br>  <br>  <br> opt=True<br> opt@spi_type = 3 <br>  <br>  <br>  plot = new (1, "graphic")<br><br>  do nr=0,nrun-1<br>    spi    = dim_spi_n(prc, runlen(nr), False, 0)<br><br>   ; spi@long_name = "SPI"<br>   ; spi@units = "run="+runlen(nr)<br>    copy_VarCoords(prc, spi)<br>   spi_mask   = shapefile_mask_data(spi,shp,opt)<br>end do<br><br><br>    <br>   opt         = True<br> ; opt@minlat  = min(spi&latitude)<br> ; opt@maxlat  = max(spi&latitude)<br> ; opt@minlon  = min(spi&longitude)<br> ; opt@maxlon  = max(spi&longitude)<br> ; spi_mask    = shapefile_mask_data(spi,shp,opt)<br> <br><br> <br>  res@mpMinLatF       := min(slat)<br>  res@mpMaxLatF       := max(slat)<br>  res@mpMinLonF       := min(slon)<br>  res@mpMaxLonF       := max(slon)<br><br><br>  ;  res@gsnCenterString  = "1901-1910"                                        <br>  ;  plot(0) = gsn_csm_contour_map(wks,spi_mask({201012},:,:), res) <br><br>  ;  gsn_panel(wks,plot,(/1,1/),resP)          ; now draw as one plot<br>;end do<br><br> <br>;--------------------------------<br>; Create plot of masked data<br>;--------------------------------<br>  plot = gsn_csm_contour_map(wks,spi_mask({195012},:,:), res)<br>;end do<br>;---Add shapefile outlines to plots<br><br>  lnres             = True<br>  lnres@gsLineColor = "NavyBlue"<br>  id_mask           = gsn_add_shapefile_polylines(wks,plot_mask,shp,lnres)<br><br><br>draw(plot_mask)<br>frame(wks)<br></div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<font color="#888888"><br clear="all"></font></div></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><span style="color:rgb(68,68,68)">|| with regards ||</span><font style="color:rgb(102,102,102)" size="2"><b><i><br><br></i></b></font></div><span style="color:rgb(68,68,68)"><b>Pawan Kumar Chaubey <a href="https://publons.com/researcher/4455812/pawan-kumar-chaubey/" target="_blank"><img src="https://publons.com/static/images/badge/rid_badge_small.png"></a></b></span><br>Senior Research Fellow<br>
DST- Mahamana Center of Excellence in Climate Change Research<br>
Institute of Environment & Sustainable Development</div><div dir="ltr"><span><span>Banaras Hindu University, Varanasi , India<br></span></span></div><div dir="ltr">---------------------------------------------------------------------------<br><div>
</div></div><div dir="ltr">MSc.(Tech.) , Geophysics</div><div dir="ltr"><span></span></div><div dir="ltr">Ph. +919455591662</div></div><div dir="ltr"><br></div><div dir="ltr"><a href="https://publons.com/researcher/4455812/pawan-kumar-chaubey/" target="_blank"><img src="https://publons.com/static/images/badge/rid_badge_large.png"></a><br></div><div dir="ltr"><br></div><div dir="ltr"><a href="https://bhu.irins.org/profile/207255" target="_blank">https://bhu.irins.org/profile/207255</a><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>