<div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Correct, but I wouldn't call it "subsetting" your data, as you are actually masking it.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">So, you can have all the counties in one big shapefile, or in individual shapefiles.  It's easier if it's in one, but it will work if it's in several. You have to do a few extra steps if the counties are in several shapefiles.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The shapefile_mask_data function loops through all the possible segments of all features in a shapefile and checks every point in your data to see if it's inside one of those segements. If it is, then it doesn't do anything to that data location. If it isn't, then it sets that data location to missing.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">What you end up with, then, is a masked array of the same size as your original data array, but with some values set to missing.  </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">In the script I set you, instead of returning the masked data array, I returned a special array of 0s and 1s that serves as a mask that you can apply to your data.  You could write this mask array to a file and then read it in later to apply it to other data arrays that are the same size. This will make things faster.</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><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 19, 2018 at 5:13 PM Toni Klemm <<a href="mailto:toni-klemm@tamu.edu">toni-klemm@tamu.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 style="overflow-wrap: break-word;">Hi Mary!<div><br></div><div>Do you mean if I left the individual counties in the shapefile as separate features, then NCL wouldn’t have trouble subsetting my data?</div><div><br></div><div>Thanks,</div><div>Toni<br><div><div>
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="color:rgb(0,0,0);font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri"><br class="gmail-m_7372301132504351468Apple-interchange-newline"><br></font></div><div style="color:rgb(0,0,0);font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri"><b>Toni Klemm, Ph.D.<br></b>Postdoctoral Research Associate</font></div><div style="color:rgb(0,0,0);font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Department of Ecosystem Science and Management</div><div style="color:rgb(0,0,0);font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">College of Agriculture and Life Sciences</div><div style="color:rgb(0,0,0);font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Texas A&M University, College Station, TX</div><div style="color:rgb(0,0,0);font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri">Contributor to the <a href="http://www.eccforum.org" target="_blank">Early Career Climate Forum</a><br><a href="http://www.toni-klemm.de" target="_blank">www.toni-klemm.de</a> | <a href="http://twitter.com/toniklemm" target="_blank">@toniklemm</a></font></div><div style="color:rgb(0,0,0);font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri"><br></font></div><div style="color:rgb(0,0,0);font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri"><br></font></div></div></div><br class="gmail-m_7372301132504351468Apple-interchange-newline"></div><br class="gmail-m_7372301132504351468Apple-interchange-newline"></div><br class="gmail-m_7372301132504351468Apple-interchange-newline"></div><br class="gmail-m_7372301132504351468Apple-interchange-newline"><br class="gmail-m_7372301132504351468Apple-interchange-newline">
</div>
<div><br><blockquote type="cite"><div>On Dec 19, 2018, at 5:06 PM, Mary Haley <<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>> wrote:</div><br class="gmail-m_7372301132504351468Apple-interchange-newline"><div><div dir="ltr" style="font-family:Calibri;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div class="gmail_default" style="font-size:small">Hi Toni,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Your shapefile has just one feature and several segments for that feature.  Usually the shapefiles we see have several features and several segments for each feature. Your shapefile is a little unusual, but not unheard of.  Unfortunately, the examples we have all do the averaging across shapefile *features* and not shapefile *segments*.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">This doesn't mean you can't do it with NCL.  See the attached plot, where I contoured some dummy 2D data over the area of interest and then generated a second plot where the values were averaged based on whether they fell inside one of these segments.  Is this what you are trying to accomplish?  If so, I'll clean up the code and send it to you.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div></div><br style="font-family:Calibri;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div class="gmail_quote" style="font-family:Calibri;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="ltr">On Wed, Dec 19, 2018 at 1:26 PM Toni Klemm <<a href="mailto:toni-klemm@tamu.edu" target="_blank">toni-klemm@tamu.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>Hello All,<div><br></div><div>I am trying to use a shapefile of merged counties in the western Great Plains to create a spatial subset of temperature and precipitation data and calculate averages and totals for those counties as a whole. However, the data subset doesn't look anything like the shapefile (see the Panoply screenshot). I attached the shapefile as GIS files and screenshot. </div><div><br></div><div>My guess is that NCL gets confused about the disconnected-yet-combined counties and doesn't know how to process a shapefile like that. Does anyone know what I can do to make this work? Can I manipulate the shapefile data in QGIS somehow so NCL understands it? Alternatively I could process each county by itself and then average the results. But there are over 100 counties, which would take a very long time. </div><div><br></div><div>I appreciate any help!</div><div><br></div><div>Thank you very much,</div><div>Toni<br><div><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri"><br class="gmail-m_7372301132504351468gmail-m_-6586768839414286389Apple-interchange-newline"><br></font></div><div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri"><b>Toni Klemm, Ph.D.<br></b>Postdoctoral Research Associate</font></div><div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Department of Ecosystem Science and Management</div><div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">College of Agriculture and Life Sciences</div><div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Texas A&M University, College Station, TX</div><div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri">Contributor to the <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.eccforum.org&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=S4Vpn9B9dGEDj8PfFUyL3ZZyY6XSazVZ50UULc2pwEU&s=_wmxrfPQsMF3vojIFKRAtdhltlvptw6M4HZ9fLg_3cQ&e=" target="_blank">Early Career Climate Forum</a><br><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.toni-2Dklemm.de&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=S4Vpn9B9dGEDj8PfFUyL3ZZyY6XSazVZ50UULc2pwEU&s=BUcEg1gjQSTNzMQTj8-c30-A9wVn4XtHJXwJ98GJFdc&e=" target="_blank">www.toni-klemm.de</a> | <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__twitter.com_toniklemm&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=S4Vpn9B9dGEDj8PfFUyL3ZZyY6XSazVZ50UULc2pwEU&s=4uj7i-TM4DYGnhfVvqE6_pSkQa5N6ZthvK0BCZWNzK8&e=" target="_blank">@toniklemm</a></font></div><div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri"><br></font></div><div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><font face="Calibri"><br></font></div></div></div><br class="gmail-m_7372301132504351468gmail-m_-6586768839414286389Apple-interchange-newline"></div><br class="gmail-m_7372301132504351468gmail-m_-6586768839414286389Apple-interchange-newline"></div><br class="gmail-m_7372301132504351468gmail-m_-6586768839414286389Apple-interchange-newline"></div><br class="gmail-m_7372301132504351468gmail-m_-6586768839414286389Apple-interchange-newline"><br class="gmail-m_7372301132504351468gmail-m_-6586768839414286389Apple-interchange-newline"></div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></div><div><div></div></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="https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=S4Vpn9B9dGEDj8PfFUyL3ZZyY6XSazVZ50UULc2pwEU&s=PmMsnjl-ihptp2YXVfcxUt782zRG1XbIMrqgS8bUQZg&e=" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br></blockquote></div><span id="gmail-m_7372301132504351468cid:f_jpvsb4r80"><shapefile.000002.png></span></div></blockquote></div><br></div></div></div></blockquote></div>