<div dir="ltr"><div class="gmail_default" style="font-size:small">Is what you are asking for similar to example &quot;mask_8.ncl&quot; at:<br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style><a href="http://www.ncl.ucar.edu/Applications/mask.shtml#ex8">http://www.ncl.ucar.edu/Applications/mask.shtml#ex8</a><br></div><div class="gmail_default" style><br></div><div class="gmail_default" style>where you are not creating a separate masked data array, but rather you are drawing the full set of contours, but just filling in the areas that you are not interested in with another color, like white?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">NCL can do this kind of this with the map databases that are built into NCL, but not with generic shapefile outlines that you give it.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">What I think you have to do is figure out how to fill in the area *outside* the shapefile polygon in white.</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><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 27, 2014 at 12:32 AM, Kreienkamp Frank <span dir="ltr">&lt;<a href="mailto:Frank.Kreienkamp@dwd.de" target="_blank">Frank.Kreienkamp@dwd.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="DE" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Hello</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">the solution provided by Mary
</span><span lang="EN-GB" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">looks very interesting. Thanks a lot for your effort Mary. Now I have to start to understand what happens, to learn to find similar solutions. My first question
 looks to be solved completely. <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Jagan TNAU is correct with the statement that there is still a solution missing for my second question. I am not sure if it is possible to reverse
 one certain shape function. To fill not the region inside the shape but to fill the region outside the shape. Unfortunately this has to be applied for the coloured pixel points after creating the map and not with the original data used the create the map.
 What means that, is there a way to manipulate the created pixel values in the map? Is there a matrix of colour information (wtype@wkWidth x wtype@wkHeight) ? Our the values it self before transferring those values to colour information? Can this matrix be
 manipulated?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Thanks in advance<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Frank<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Von:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a> [mailto:<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a>]
<b>Im Auftrag von </b>Mary Haley<br>
<b>Gesendet:</b> Mittwoch, 26. November 2014 17:46<br>
<b>An:</b> Kreienkamp Frank<br>
<b>Cc:</b> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Betreff:</b> Re: [ncl-talk] ncl and shape<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Frank,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I&#39;m not sure if this is the best solution, but I modified shapefile_mask_data to mask both on whether the grid point falls inside the shapefile area (using gc_inout as before) *and* whether it is within a certain kilometer distance from
 the shapefile border (using gc_latlon).  <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">gc_latlon returns the great circle distance between a series of lat/lon points, and you can use it to return the distance in meters, kilometers, degrees, or radians. I used option 4 (kilometers).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/gc_latlon.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Built-in/gc_latlon.shtml</a><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">See the attached example script, and try running it with different values for &quot;delta_kilometers&quot;.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">  delta_kilometers = 300<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Note that this script can take awhile to run if you have a lot of data points, or a lot of shapefile areas to check against. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">It is possible to make this script much more efficient by limiting the area that is actually checked.  For example, inside the big &quot;do n=0,natlon1d-1&quot; loop in the shapefile_mask_data&quot; function, you could add a &quot;if&quot; check for lat1d or lon1d
 being less than/greater than some min/max lat/lon box, and then &quot;break&quot; out of that loop if the condition is not met.  This way, you don&#39;t get into the tedious checking with gc_inout and/or gc_latlon.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The original &quot;shapefile_mask_data&quot; actually does this kind of checking, so you can look at that for more informatioin.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I&#39;ve attached the modified function, and example script (based on shapefiles_16.ncl), with PNGs showing the results with 100, 200, and 300 km.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I also attached a PNG showing the original results where you just mask based on the shapefile area.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">--Mary<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Mon, Nov 24, 2014 at 10:54 PM, Kreienkamp Frank &lt;<a href="mailto:Frank.Kreienkamp@dwd.de" target="_blank">Frank.Kreienkamp@dwd.de</a>&gt; wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Hello,</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">i have two questions about the interaction of ncl and shape files. 
</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">1)</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Using ‘shapefile_mask_data’ I can mask out grid points lying inside a shape file.  One result is shown in the attached png-file. Is it possible to define an extention,
 that I get all grid point inside and additional the grid point which are close (  xx km)  to the shape-polygon-border?</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">2)</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">I am looking for a function which cuts out and draws the complete region. In the shown example i have white areas based along the shape-polygon-border. But I
 want to have the complete area inside the shape-polygon-border colored.</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US">Thanks in advance</span><u></u><u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#888888">Frank</span><span style="color:#888888"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#888888"> </span><span style="color:#888888"><u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>