<div dir="ltr"><div><div><div>Hi Sean,<br><br></div>I see the issue -- gsn_add_shapefile_polylines is drawin all the lines, not leaving any opportunity to change the value of gsLineLabelString.  (BTW:  I couldn&#39;t run your script -- NCL is complaining the shapefile is corrupt?  GDAL seems to be able to at least peak into it however. Not sure what&#39;s going on here).<br><br></div>One thing that comes to mind is to draw the lines yourself, much the way gsn_add_shapefile_polylines does under the hood. The code for that looks something like this (UNTESTED, but comes straight out of the 1st example at <a href="http://ncl.ucar.edu/Applications/shapefiles.shtml">http://ncl.ucar.edu/Applications/shapefiles.shtml</a>):<br><br></div>  ; get needed info out of shapefile<br><div>  shapefile = &quot;mp143-mpua5-contour.shp&quot;<br>  f = addfile(shapefile,&quot;r&quot;)<br><br><pre>  segments = f-&gt;segments
  geometry = f-&gt;geometry
  segsDims = dimsizes(segments)
  geomDims = dimsizes(geometry)
;
; Read global attributes  
;
  geom_segIndex = f@geom_segIndex
  geom_numSegs  = f@geom_numSegs
  segs_xyzIndex = f@segs_xyzIndex
  segs_numPnts  = f@segs_numPnts

  lines       = new(segsDims(0),graphic)   ; Array to hold polygons
  numFeatures = geomDims(0)

  lon   = f-&gt;x
  lat   = f-&gt;y
</pre>; ******** your code here ******************<br><br></div><div>  ; draw the lines...<br><br><pre>  segNum = 0
  do i=0, numFeatures-1  
     pres@gsLineLabelString = labels(i)  ;; &lt;&lt;========
     startSegment = geometry(i, geom_segIndex)
     numSegments  = geometry(i, geom_numSegs)
     do seg=startSegment, startSegment+numSegments-1
        startPT = segments(seg, segs_xyzIndex)
        endPT = startPT + segments(seg, segs_numPnts) - 1
        lines(segNum) = gsn_add_polygon(wks, map, lon(startPT:endPT),  \
                                                   lat(startPT:endPT), pres)
        segNum = segNum + 1
     end do
  end do
</pre><br><br><br></div><div>I hope this helps...<br></div><div>Rick<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 9, 2016 at 11:58 AM, Sean Egan <span dir="ltr">&lt;<a href="mailto:sdegan@alaska.edu" target="_blank">sdegan@alaska.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Dear NCL Community,<br><br></div><div>I have a shape file containing 3 polyline segments. Each segment is a &quot;contour&quot; level and these level values are stored in the CONTOUR variable. See the description of the shape file below.<br><br>ncl 0&gt; f = addfile(&quot;mp143-mpua5-contour.s<wbr>hp&quot;,&quot;r&quot;)<br>ncl 1&gt; print(f)<br><br>Variable: f<br>Type: file<br>filename:    mp143-mpua5-contour<br>path:    mp143-mpua5-contour.shp<br>   file global attributes:<br>      layer_name : mp143-mpua5-contour<br>      geometry_type : polyline<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 = 3  // unlimited<br>      num_segments = 3<br>      num_points = 149<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>      string CONTOUR ( num_features )<br><br></div><div><div>When I plot these shape files, I want to label each segment with the contour level. I am trying to do this by setting labels=f-&gt;CONTOUR and then setting the gsLineLabelString resource equal to &quot;labels&quot;. This, however, labels each segment with the first entry in labels (labels(0)), instead of each segment with each value. See the description of labels below.<br><br>ncl 5&gt; print(labels)<br><br><br>Variable: labels<br>Type: string<br>Total Size: 24 bytes<br>            3 values<br>Number of Dimensions: 1<br>Dimensions and sizes:    [num_features | 3]<br>Coordinates: <br>Number Of Attributes: 0<br>(0)    1,000<br>(1)    10<br>(2)    100<br><br></div><div>So in the output, each segment is given a value of 1,000.<br></div><div><br></div><div>Is there a way that I can either 1) label each segment with the values in labels or 2) convert the polylines to polygons and shade each a different color?<br><br></div><div>The NCL script is below (and is attached) as well as the shape files. <br><br></div><div>Thanks again for your help!<br></div><div>Sean<br><br>load &quot;$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_code.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_csm.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/wrf/WRFUserARW.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/contributed.ncl&quot;<br><br>begin<br><br>  shapefile = &quot;mp143-mpua5-contour.shp&quot;<br>  f = addfile(shapefile,&quot;r&quot;)<br><br>  b = addfile(&quot;wrf_redoubt_domain&quot;+&quot;<wbr>.nc&quot;,&quot;r&quot;)<br><br>  wks = gsn_open_wks(&quot;x11&quot;,&quot;testing&quot;)<br><br>  lat = f-&gt;y<br>  lon = f-&gt;x<br><br>  gsn_define_colormap(wks,&quot;WhBlG<wbr>rYeRe&quot;)<br>  res                         = True<br>  res@gsnMaximize             = False<br>  res@gsnDraw                 = False        ; Turn off for now.<br>  res@gsnFrame                = False        ; Will draw later<br><br>  res@tiMainOn                = False<br><br>  mpres                         <wbr>     = res<br>  mpres                         <wbr>     = wrf_map_resources(b,mpres)<br>  mpres@mpOutlineBoundarySets   <wbr>     = &quot;GeophysicalAndUSStates&quot;<br>  mpres@mpFillOn                <wbr>     = False<br>  mpres@mpOutlineOn             <wbr>     = True<br>  mpres@mpCountyLineThicknessF  <wbr>     = 2.5<br>  mpres@mpGeophysicalLineThickne<wbr>ssF  = 2.5<br>  mpres@mpNationalLineThicknessF<wbr>     = 2.5<br>  mpres@mpProvincialLineThicknes<wbr>sF   = 2.5<br>  mpres@mpUSStateLineThicknessF <wbr>     = 2.5<br>  mpres@mpCountyLineColor       <wbr>     = &quot;Black&quot;<br>  mpres@mpGeophysicalLineColor  <wbr>     = &quot;Black&quot;<br>  mpres@mpNationalLineColor     <wbr>     = &quot;Black&quot;<br>  mpres@mpUSStateLineColor      <wbr>     = &quot;Black&quot;<br><br>  mpres@mpRightCornerLonF = 215.0<br>  mpres@mpRightCornerLatF = 64.5<br>  mpres@mpLeftCornerLonF  = 200.0<br>  mpres@mpLeftCornerLatF  = 55.5<br><br>  print(mpres)<br><br>  map = gsn_csm_map(wks, mpres)<br><br>  labels=f-&gt;CONTOUR<br><br>  pres                          <wbr>     = res<br>  pres@gsLineColor              <wbr>     = &quot;Red&quot;<br>  pres@gsMarkerIndex            <wbr>     = 16<br>  pres@gsMarkerColor            <wbr>     = &quot;Red&quot;<br>  pres@gsLineLabelString        <wbr>     = labels<br><br>  poly = gsn_add_shapefile_polylines(wk<wbr>s,map,shapefile,pres)<br><br>  draw(map)<br>  frame(wks)<br><br>end<span class="HOEnZb"><font color="#888888"><br><br><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font size="1">PO1 Sean D. Egan, US Navy<br></font><font size="1">PhD Candidate<br></font><font size="1">Geophysical Institute<br></font><div><font size="1">University of Alaska Fairbanks<br></font></div><div><font size="1">903 Koyukuk Drive<br>Fairbanks, AK 99775<br><a href="mailto:sdegan@alaska.edu" target="_blank">sdegan@alaska.edu</a> | <a href="tel:907%20474-5483" value="+19074745483" target="_blank">907 474-5483</a><br></font></div><font size="1">IARC Office 334 | <a href="http://www.gi.alaska.edu/%7Esdegan" target="_blank">www.gi.alaska.edu/~sdegan</a><br></font></div></div></div></div></div></div>
</div></font></span></div></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>