<div dir="ltr"><div>Can you either i) provide the shapefile (and I'll point out that means the .shp, .shx, .dbf files), or perhaps show us the results of <br></div><div><br></div><div>   ncl_filedump District_Boundary.shp</div><div><br></div><div>Rick</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 8, 2020 at 7:24 AM Ajay Bankar via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear NCL Users,<div>                            I'm trying to make spatial plot of rainfall from station data available in csv file. I tried different options in resources but data is not masking with shapefile. </div><div>I have attached plot and data file for reference.</div><div><br></div><div>Thanks for any help!</div><div><br></div><div>Here is my script    </div><div><br></div><div>load "/shp.ncl"                      </div><div><br><div><div>begin <br> ;-- shapefile name<br> shp_filename = "/scratch/Administrative_Boundary_Headquarters/District_Boundary.shp" <br><br></div><div> infile = "station_data.csv"<br> lines = asciiread(infile, -1, "string")<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> <br>;-- 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, "station_plot") <br> ;-- 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<br>    res@cnFillOn               =  True<br>    res@cnLinesOn              =  False<br>    res@cnLineLabelsOn         =  False<br>    res@cnFillPalette          = cmap                         ;"BlueYellowRed"<br>    res@cnLevelSelectionMode   = "ExplicitLevels"               ;-- manually set contour levels<br>    res@cnLevels        = (/5,20,35,50,65,80,95,110,125,140,155/)<br>    res@gsnAddCyclic           = False<br>  <br>    res@mpGridLineColor        =  0                          ;"grey40" <br>    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>   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)<br>     frame(wks)<br> end<br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div><b>Thanks & Regards,<br></b></div><b>Ajay<br></b></div><b><br></b></div></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>