<div dir="ltr"><div>Ajay,</div><div><br></div><div>Thanks for sending the files. I experimented with this for a good while and learned something I was not aware of. First I'd point out that when working with irregularly spaced point data, NCL must employ a triangulation of the data, and it is not uncommon to see strange-ish linear contour lines along the outer edges of a resultant contour plot, particularly if the point data has a concave shape, which your's does.<br></div><div><br></div><div>So what I realized is that shapefile_mask_data() works in *data* space, not in *graphics* space (i.e., contour lines). All of the station points in your dataset are obviously inside the boundaries of the shapefile, so it returns a mask that is all 1's (inside). Then the contouring algorithm runs against that result, which in effect is the entire original concave dataset. The inevitable "strange-ish" contour lines form, but they are in graphics space, and hence, they are not clipped against the shapefile.</div><div><br></div><div>So...I'm not sure what to tell you. One possibility would be to interpolate a regular grid from the station data (I plotted the individual stations and they seem to be quite dense, so that the resultant grid might make a good representation). That said, I don't know offhand what facilities are available for doing that -- perhaps that's a separate post to ncl-talk.</div><div><br></div><div>Wish I had a better answer, but I hope that helps explain what it going on.</div><div><br></div><div>Rick</div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 8, 2020 at 8:03 PM Ajay Bankar <<a href="mailto:ajaybankar123@gmail.com">ajaybankar123@gmail.com</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">Hi Rick,<div> The same shapefile works fine with GPM data and wrf output data but only having issue with station data. Please find attached shapefiles. I have attached one plot in which I have used same shapefile for wrf model output and GPM data. Here plots (a,b,c) represents wrf plots and (d) represent GPM data plot and (e) represent station data plot. </div><div><br></div><div>This is the output of ncl_filedump District_Boundary.shp</div><div><br></div><div>Variable: f<br>Type: file<br>filename: District_Boundary<br>path: District_Boundary.shp<br> file global attributes:<br> layer_name : District_Boundary<br> geometry_type : polygon<br> geom_segIndex : 0<br> geom_numSegs : 1<br> segs_xyzIndex : 0<br> segs_numPnts : 1<br> dimensions:<br> geometry = 2<br> segments = 2<br> num_features = 30 // unlimited<br> num_segments = 33<br> num_points = 164066<br> variables:<br> integer geometry ( num_features, geometry )<br><br> integer segments ( num_segments, segments )<br><br> double x ( num_points )<br><br> double y ( num_points )<br><br> double PERIMETER ( num_features )<br><br> double AREA ( num_features )<br><br> int64 ID ( num_features )<br><br> string DIST_NAME ( num_features )<br><br> double SQ_KMS ( num_features )</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 9, 2020 at 4:50 AM Rick Brownrigg <<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@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"><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" target="_blank">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>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div><b>Thanks & Regards,<br></b></div><b>Ajay Bankar.<br></b></div><b><br></b></div></div>
</blockquote></div>