<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Rick has some good suggestions about checking your shapefile and that it must be polygonal.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">To check if you have a polygon-based shapefile, you can type this on the UNIX command line:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><span style="font-size:12.8px">ncl_filedump /public/home/huanglei/map/</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">shaanxi_city_l.shp | grep </span>geometry_type<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">and it should come back with:</div><div class="gmail_default" style="font-size:small">
<p class=""><span class=""> geometry_type : polygon</span></p></div><div class="gmail_default" style="font-size:small">Finally, to further debug this program, you can turn on an unadvertised "debug" feature. You need to call shapefile_mask_data with:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><div style="color:rgb(80,0,80)"> opt = True</div><div style="color:rgb(80,0,80)"> opt@debug = True</div><div style="color:rgb(80,0,80)"> final= shapefile_mask_data(griddata,s<wbr>hp_filename,opt)</div><div><br></div></div><div class="gmail_extra"><div class="gmail_default" style="font-size:small">If you could provide us with the output from the "debug" results, that might help.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thanks,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"></div><br><div class="gmail_quote">On Wed, Aug 10, 2016 at 10:02 PM, Rick Brownrigg <span dir="ltr"><<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>></span> wrote:<br><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><div><div><div>Hi,<br><br></div>I looked at this, but can not really tell what's going on without knowing more about the data. There are two shapefiles, shaanxi_city_l.shp, and xian.shp. I presume one of these is used to draw the subregional boundaries in your plot (which one)? What is the other? Are these both polygonal shapefiles? Perhaps plot them in two different colors to make sure they are what you think they are?<br><br></div>Without access to the data, I'm not sure what else to suggest....<br></div>Wish I could be of more help.<br></div>Rick <br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Aug 10, 2016 at 2:54 AM, grace <span dir="ltr"><<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5"><div>Hi:</div><div> All,I am trying to mask data with shapefile according to the example shapefiles_14_mask.ncl on the NCL website.</div><div>B<span style="line-height:1.5">ut most data disappeared after mask.</span></div><div><span style="line-height:1.5">The right plot is the plot after mask,the left one is the original plot.</span></div><div><span style="line-height:1.5"><br></span></div><div><img src="cid:FCC3B4E7@ABD5F612.C3EBAA57.jpg" style="width: 487px; min-height: 195px;"></div><div>This is my script:</div><div><div>; Example script to produce precip plots with satationdata,</div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_csm.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/contributed.ncl"</div><div><br></div><div>load"/public/home/huanglei/map<wbr>/shapefile_mask_data.ncl"</div><div>begin</div><div> station_file ="/public/home/huanglei/data/2<wbr>0160724/stationdata_20160724.t<wbr>xt" </div><div> data = asciiread(station_file,-1,"str<wbr>ing")</div><div> num_att = numAsciiCol(station_file) ;return the number of columns of the stationfile</div><div> print(num_att)</div><div><br></div><div> lon_station1 = stringtofloat(str_get_field(da<wbr>ta(0:1889),2," "))</div><div> lat_station1 = stringtofloat(str_get_field(da<wbr>ta(0:1889),3," "))</div><div> obs_precip1 = stringtofloat(str_get_field(da<wbr>ta(0:1889),4," "))</div><div><br></div><div><br></div><div> olon = fspan(105.5,110.9,100)</div><div> olat = fspan(31.5,35.8,100)</div><div><br></div><div> olon!0 = "lon"</div><div> olon@long_name = "lon"</div><div> olon@units = "degrees-east"</div><div> olon&lon = olon</div><div> olat!0 = "lat"</div><div> olat@long_name = "lat"</div><div> olat@units = "degrees_north"</div><div> olat&lat = olat</div><div> print("......")</div><div> obs_precip1@_FillValue = -999.000000</div><div> rscan = (/0.5,0.2,0.1/) </div><div> griddata = obj_anal_ic_deprecated(lon_sta<wbr>tion1,lat_station1,obs_precip1<wbr>,olon,olat,rscan,False)</div><div>;;;;;;;;;;;;;;;;;;;;;;mask data with shapfile;;;;;;;;;;;;;;;;;;;</div><div> shp_filename = "/public/home/huanglei/map/sha<wbr>anxi_city_l.shp"</div><div> final= shapefile_mask_data(griddata,s<wbr>hp_filename,True)</div><div> ; exit</div><div> wks = gsn_open_wks ("pdf","rain20160724") </div><div> </div><div> res = True </div><div> res@gsnMaximize = True</div><div> res@gsnDraw = False</div><div> res@gsnFrame = False</div><div><br></div><div>;>----------------------------<wbr>----------------<</div><div>; set for the map </div><div>;>----------------------------<wbr>----------------<</div><div> res@mpMinLatF = 31.5 </div><div> res@mpMaxLatF = 35.8</div><div> res@mpMinLonF = 105.5</div><div> res@mpMaxLonF = 110.9</div><div> res@tmXBMode = "Explicit" </div><div> res@tmXBValues = (/106,107,108,109,110/) </div><div> res@tmXBLabels = (/"106~S~o~N~E","107~S~o~N~E",<wbr>"108~S~o~N~E","109~S~o~N~E","1<wbr>10~S~o~N~E"/) </div><div> ; res@tmXBMinorValues = fspan(97,109,30) </div><div> ; res@tmXBMinorOn = True </div><div> </div><div> res@tmYLMode = "Explicit" </div><div> res@tmYLValues = (/32,33,34,35/) </div><div> res@tmYLLabels = (/"32~S~o~N~N","33~S~o~N~N","3<wbr>4~S~o~N~N","35~S~o~N~N"/) </div><div> ;res@tmYLMinorValues = fspan(26,36,20) </div><div> ;res@tmYLMinorOn = True </div><div><br></div><div> res@mpFillOn = True</div><div> res@mpOutlineOn = False </div><div> res@cnFillDrawOrder = "PreDraw"</div><div> res@mpDataBaseVersion = "MediumRes"</div><div> res@mpDataSetName = "Earth..4"</div><div> res@mpAreaMaskingOn = True</div><div> res@mpLandFillColor = "white"</div><div> res@mpInlandWaterFillColor = "white"</div><div> res@mpOceanFillColor = "white"</div><div> res@mpOutlineBoundarySets = "NoBoundaries"</div><div><br></div><div>;>----------------------------<wbr>----------------<</div><div>; set for the plot</div><div>;>----------------------------<wbr>----------------<</div><div><br></div><div> res@cnFillOn = True </div><div> res@cnLinesOn = False </div><div> ; res@cnLevelSpacingF = 0.2 </div><div> res@gsnSpreadColors = True </div><div> res@lbLabelAutoStride = True</div><div> res@gsnAddCyclic = False </div><div> </div><div> res@cnLevelSelectionMode = "ExplicitLevels"</div><div> res@cnLevels = (/ .1, .4, .8, 1.6, 3.2, 6.4, \</div><div> 12.8, 25.6, 51.2,100/)</div><div> res@cnFillColors = (/"White","DarkOliveGreen1", \</div><div> "DarkOliveGreen3","Chartreuse"<wbr>, \</div><div> "Chartreuse3","Green","ForestG<wbr>reen", \</div><div> "Yellow","Orange","Red","Viole<wbr>t"/)</div><div> map = gsn_csm_contour_map(wks,final,<wbr>res) </div><div><br></div><div>;>----------------------------<wbr>------------------------------<wbr>--<</div><div>; add map</div><div>;>----------------------------<wbr>------------------------------<wbr>--<</div><div><br></div><div> shp_name1 = "/public/home/huanglei/map/xia<wbr>n.shp"</div><div> shp_name2 = "/public/home/huanglei/map/sha<wbr>anxi_city_l.shp"</div><div> lnres = True</div><div> lnres@gsLineColor = "gray25"</div><div> lnres@gsLineThicknessF = 1.5 </div><div><br></div><div> id = gsn_add_shapefile_polylines(wk<wbr>s,map,shp_name1,lnres)</div><div> id2= gsn_add_shapefile_polylines(wk<wbr>s,map,shp_name2,lnres)</div><div>;>----------------------------<wbr>------------------------------<wbr>--<</div><div> </div><div> ; station = asciiread("/public/home/huangl<wbr>ei/data/prcdata.txt",(/160,3/)<wbr>,"float") </div><div> </div><div> res2 = True </div><div> res2@gsMarkerIndex = 16 </div><div> res2@gsMarkerSizeF = 6. </div><div> res2@gsMarkerColor = "Violet" </div><div> res2@tfPolyDrawOrder = "PostDraw" </div><div> res2@cnFillDrawOrder = "PostDraw" </div><div> ;</div><div> plots1=gsn_add_polymarker(wks<wbr>,map,108.9373,34.2158,res2)</div><div> plots2=gsn_add_polymarker(wks<wbr>,map,108.9133,34.2303,res2)</div><div> plots3=gsn_add_polymarker(wks<wbr>,map,108.8908,34.1953,res2)</div><div><br></div><div> ; plots=gsn_add_polymarker(wks,m<wbr>ap,station(:,1),station(:,2),r<wbr>es2)</div><div> delete(res2) </div><div> draw(map)</div><div> frame(wks)</div><div> end </div></div><div><span style="font-family:"lucida Grande",Verdana,"Microsoft YaHei";line-height:23.8px"> How can I slove the problem?</span></div><div></div><br></div></div>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>