<div dir="ltr"><div>Dear NCL Users,</div><div>                       I'm trying to make spatial plot of rainfall from station data available in csv file. I wrote the following script but data is not masking with shapefile. Also I'm getting the warning as:</div><div><b>warning:tofloat: A bad value was passed to (string) tofloat, input strings must contain numeric digits, replacing with missing value.</b></div><div>I have attached plot and sample data file for reference. </div><div><br></div><div>Thanks for any help!</div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>load "/scratch/rakesh/WRF-AJAY/WRFV3/RUN_14AUG/NCL_PROGRAM/shp.ncl"<br> </div><div>begin <br> ;-- shapefile name<br> shp_filename = "/scratch/Administrative_Boundary_Headquarters/District_Boundary.shp" <br> infile = "/scratch/rakesh/WRF-AJAY/DATASETS/STATION/station_data_final.csv"<br> lines = asciiread(infile, -1, "string")<br>;print(lines)<br>;delim = ","<br><br>rain = tofloat( str_get_field(lines(1:), 7, ","))<br>rain@lat1d  = tofloat( str_get_field(lines(1:), 5, ","))<br>rain@lon1d  = tofloat( str_get_field(lines(1:), 6, ","))<br>;print(rain)<br> </div><div>;-- define sub-region, here for Karnataka<br>     minlat =  11<br>     maxlat =  19<br>     minlon =  73.5<br>     maxlon =  79.1<br> <br>;-- open workstation<br>     wks_type          = "pdf"<br>     wks  = gsn_open_wks(wks_type,"1_station_plot") <br><div> ;-- resource settings<br>     res                        =  True<br>     res@gsnDraw                =  False                       ;-- don't draw plot yet<br>     res@gsnFrame               =  False                       ;-- don't advance frame yet<br>     res@gsnMaximize            =  True                        ;-- maximize plot in frame<br> <br>  ;  res@tfDoNDCOverlay        = True<br><br>    cmap     := read_colormap_file("BlAqGrYeOrReVi200")<br>    cmap(0,:) = (/0,0,0,0/)    ; make first color fully transparent</div><div>    res@cnFillOn               =  True<br>    res@cnLinesOn              =  False<br>    res@cnLineLabelsOn         =  False<br>    res@cnFillPalette          = cmap                         ;"BlueYellowRed"<br>    res@cnLevelSelectionMode   = "ManualLevels"               ;-- manually set contour levels<br>    res@cnMinLevelValF         = 5                            ; 260.0                       ;-- contour min lev<br>    res@cnMaxLevelValF         = 95                           ; 280.0                       ;-- contour max lev<br>    res@cnLevelSpacingF        = 10                           ;   0.5                       ;-- contour spacing<br>    res@gsnAddCyclic           = False<br>  <br>    res@mpGridLineColor        =  0                          ;"grey40" </div><div>    res@mpFillOn               =  False<br>    res@mpOutlineOn            =  False<br>    res@mpGeophysicalLineColor = "black"<br>    res@mpLimitMode            = "LatLon"<br>    res@mpMinLatF              = minlat<br>    res@mpMaxLatF              = maxlat<br>    res@mpMinLonF              = minlon<br>    res@mpMaxLonF              = maxlon<br>    ;res@mpAreaMaskingOn        = True<br><br>   res@lbBoxMinorExtentF      =  0.1                         ;-- decrease height of labelbar boxes<br>   res@pmLabelBarOrthogonalPosF = 0.08                      ;-- move labelbar to the left side of plot<br></div><div>   res@lbBoxMinorExtentF      =  0.2                         ;-- decrease height of labelbar boxes<br><br>   res@pmTickMarkDisplayMode  = "Always"<br>   res@tmXTOn                 =  False<br>   res@tiMainString           = "STATION DATA PLOT"<br>  <br> ;-- create plot<br>    plot = gsn_csm_contour_map(wks,rain,res)<br>    var_mask = shapefile_mask_data(rain,shp_filename,True)<br> <br> ;-- create contours of masked data<br>    plot_mask = gsn_csm_contour_map(wks,var_mask,res)<br> <br> ;-- add plot_mask to plot<br>     lnres                    =  True<br>     lnres@gsLineColor        = "black"<br>     lnres@gsLineThicknessF   =  1.0<br> <br>     plot@lines = gsn_add_shapefile_polylines(wks, plot_mask, shp_filename, lnres)<br><br>  ;-- draw the plot and advance the frame<br>     draw(plot_mask)</div><div>     frame(wks)<br> end<br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div><b>Thanks & Regards,<br></b></div><b>Ajay Bankar.<br></b></div><b><br></b></div></div></div></div>