<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Leo,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">When people want to mask their data, there are usually two ways this is done. I will describe a third way below.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">[1]</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">One way is to use a shapefile outline and the shapefile_mask_data function, which checks the lat/lon locations of your data array against the outline in a shapefile, and sets your data array values to missing if the locations falls outside the shapefile outline. You can then plot your data as usual without having to set any mpXXX masking resources (like mpAreaMaskingOn), because you've already done the work of masking your data.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The one issue with this method is that when you plot it, you may get some blockiness near the inside edges of the shapefile outline, because your data's lat/lon points may not lie very close to the border of the outline. You can see an example of that in these images:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Applications/Images/shapefiles_11_lg.png" target="_blank">http://www.ncl.ucar.edu/<wbr>Applications/Images/<wbr>shapefiles_11_lg.png</a><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Applications/Images/shapefiles_16_lg.png" target="_blank">http://www.ncl.ucar.edu/<wbr>Applications/Images/<wbr>shapefiles_16_lg.png</a></div><div class="gmail_default"><br></div><div class="gmail_default">[2]</div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small">The second way, which you mentioned, is set mpAreaMaskingOn to True, and then set mpFillAreaSpecifiers and mpMaskAreaSpecifiers to the desired areas that you want to fill or mask. This method does NOT work with shapefile outlines. It only works with NCL's internal map databases. But, it does result in smooth contouring at the boundaries:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Applications/Images/mask_4_lg.png" target="_blank">http://www.ncl.ucar.edu/<wbr>Applications/Images/mask_4_lg.<wbr>png</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">[3]</div><div class="gmail_default"><br></div><div class="gmail_default">The third way is if you want to use the shapefile outline for masking, but you don't like the blockiness that you're getting with the shapefile_mask_data function.</div><div class="gmail_default"><br></div><div class="gmail_default">You draw the contours as usual, and then fill in the areas you don't want to see by using a function that draws polygons by name, given a shapefile and the name of the shapefile that contains the areas you want to fill. </div><div class="gmail_default"><br></div><div class="gmail_default">For example, let's say you didn't want to see contours over New Mexico or Colorado. You can use the USA_adm1.shp shapefile, which contains all the outlines for the US States in a variable called "NAME_1", and then pass this information to a function (that is part of the shapefiles_21.ncl example):</div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace"> shp_fname = <span style="color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">"USA_adm1.shp"</span></font></div><div class="gmail_default"><font face="monospace, monospace"><span style="color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> shp_name = "NAME_1"</span></font></div><div class="gmail_default"><font face="monospace, monospace"><span style="color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"> shp_areas = (/<div class="gmail_default" style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;display:inline">"Colorado","New Mexico</div><span style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">,</span><div class="gmail_default" style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;display:inline">"/)</div></span></font></div><font face="monospace, monospace"> opt = True<br> opt@polytype = "polygon"<br> opt@gsFillColor = "gray"</font><div><font face="monospace, monospace"><div class="gmail_default" style="font-size:small;display:inline"> </div>add_shapefile_primitives_by_name(wks,plot,<div class="gmail_default" style="font-size:small;display:inline">shp_fname,shp_vname,shp_areas,popt)</div></font></div><div><br></div><div><div class="gmail_default" style="font-size:small">shapefiles_21.ncl and the images can be seen here:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><a href="http://www.ncl.ucar.edu/Applications/shapefiles.shtml#ex21">http://www.ncl.ucar.edu/Applications/shapefiles.shtml#ex21</a></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The third frame is the one you want to look at.</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"><br></div><div class="gmail_default" style="font-size:small"></div><br></div><div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 5, 2018 at 7:16 PM, Guido Cioni <span dir="ltr"><<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</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="auto">Remember to include ncl-talk in all replies.<div dir="auto"><br></div><div dir="auto">I believe you can do that easily with the examples that I suggested to you.</div><div dir="auto"><br></div><div dir="auto">When you have masked the data using the example you can already plot it and it will look like that, provided that you turn off the normal map outline with mpOutlineOn=False.</div><div dir="auto"><br></div><div dir="auto">If you want the outline you just need to plot the shapefile with the desired region using one of the common functions. </div></div><div class="gmail_extra"><br><div class="gmail_quote">Il 6 mar 2018 12:21 PM, "Leo Niu" <<a href="mailto:leo2018niu@gmail.com" target="_blank">leo2018niu@gmail.com</a>> ha scritto:<br type="attribution"><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">Thanks for all your response.<div><img src="cid:ii_jeeyseqi0_161f8e23baeadba0" width="251" height="155"><br><p class="MsoNormal"><span style="font-family:宋体;font-size:10.5pt">I have a polygon shapefile of the blue area.And I want to mask outside of this area. Just the blue area is remained.I know the maps sources, like @mpAreaMaskongOn<font face="宋体">、</font><font face="Calibri">@mpAreaNames etc. But I don</font></span><span style="font-family:Calibri;font-size:10.5pt">’</span><span style="font-family:宋体;font-size:10.5pt">t want to use Ncarg4_0 database,even seting @mpDataBaseVersion to be </span><span style="font-family:Calibri;font-size:10.5pt">“HighRes”</span><span style="font-family:宋体;font-size:10.5pt"> . because boundaries in the database can</span><span style="font-family:Calibri;font-size:10.5pt">’</span><span style="font-family:宋体;font-size:10.5pt">t match it in my shapefile. Polylines and polygons in my shapefile are more detailed.</span><span style="font-family:宋体;font-size:10.5pt"><span></span></span></p><p class="MsoNormal"><span style="font-family:宋体;font-size:10.5pt">Finally, I</span><span style="font-family:Calibri;font-size:10.5pt">’</span><span style="font-family:宋体;font-size:10.5pt">m willing to get a plot like this:</span><span style="font-family:宋体;font-size:10.5pt"><span></span></span></p><p class="MsoNormal"><span style="font-family:宋体;font-size:10.5pt"><img src="cid:ii_jeeysrok1_161f8e27d0463d4f" width="335" height="207"><br>Is that clear?</span></p><div><br></div></div></div><div><div class="gmail-m_-757949657853941507h5"><div class="gmail_extra"><br><div class="gmail_quote">2018-03-05 21:12 GMT+08:00 Guido Cioni <span dir="ltr"><<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>></span>:<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="auto">It looks to me that example 11 in this page <a href="https://www.ncl.ucar.edu/Applications/shapefiles.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Applications/shapefiles.shtml</a> does exactly what you want to do, specifically read a shapefile, select an area to mask, save the mask to a netcdf file and then use this variable to mask the original data (i advise you to create the netcdf at first otherwise it will take so much to use the shapefile every time).<div dir="auto"><br></div><div dir="auto">Otherwise you have to explain better what you want to do ;-)</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="gmail-m_-757949657853941507m_-327568778439214602m_-2562401090746025170h5">Il 5 mar 2018 11:22 PM, "Leo Niu" <<a href="mailto:leo2018niu@gmail.com" target="_blank">leo2018niu@gmail.com</a>> ha scritto:<br type="attribution"></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="gmail-m_-757949657853941507m_-327568778439214602m_-2562401090746025170h5">
<div>
<div style="line-height:1.6;font-family:苹方,微软雅黑,sans-serif"><font style="font-size:17px"><br>I'm ploting a contour of an area. But boundries of the interest area in Ncarg4_0 database can't match with my shapefile. I have searched for ploting an area and masking outside using a polyline or polygon shapefile on <a href="http://www.ncl.ucar.edu.But" target="_blank">www.ncl.ucar.edu.But</a> I haven't found a method dealing with this. Is there some ways that can help in ploting contour of an area only inside of a geocoded polygon?<br>Thanks a lot.</font></div><u></u>
<div style="margin:0px;padding:0px">
<a href="https://maas.mail.163.com/dashi-web-extend/html/proSignature.html?iconUrl=https://mail-online.nosdn.127.net/qiyelogo/defaultAvatar.png&name=leo2018niu&uid=leo2018niu%40gmail.com&ftlId=3&items=%5B%22%E9%82%AE%E7%AE%B1%EF%BC%9Aleo2018niu%40gmail.com%22%5D" width="400" style="display:block;max-width:400px;background:rgb(255,255,255);padding:15px 0px 10px;text-decoration:none;outline:none" target="_blank">
<table cellpadding="0" style="width:100%;max-width:100%;table-layout:fixed;border-collapse:collapse;line-height:1.3;color:rgb(155,158,161);font-size:14px">
<tbody style="word-wrap:break-word;word-break:break-all;font-family:"PingFang SC","Hiragino Sans GB","WenQuanYi Micro Hei","Microsoft Yahei",微软雅黑,verdana">
<tr>
<td width="45" style="padding:0px 7px 0px 0px;box-sizing:border-box;width:45px">
<img width="38" height="38" style="width: 38px; height: 38px; border-radius: 50%;" src="https://mail-online.nosdn.127.net/qiyelogo/defaultAvatar.png">
</td>
<td style="padding:0px 0px 0px 7px">
<div style="max-width:380px">
<div style="box-sizing:border-box;padding-right:35px;font-size:16px;margin-bottom:5px;color:rgb(49,53,59);font-weight:bold;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">leo2018niu</div>
<div style="font-size:0px;line-height:0">
</div>
<div style="word-wrap:break-word;word-break:break-all">
邮箱:leo2018niu@gmail.com
</div>
</div>
</td>
</tr>
</tbody>
</table>
</a>
</div>
<div style="margin:0px"><p style="margin:0px;border-top:1px solid rgb(229,229,229);padding-top:6px;font-size:12px;color:rgb(182,184,187);line-height:1.5">签名由 <a href="https://mail.163.com/dashi/dlpro.html?from=mail88" style="color:rgb(106,168,246);text-decoration:none" target="_blank">网易邮箱大师</a> 定制</p></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></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div>
<br>______________________________<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></div></div>