<div dir="ltr"><div>Hi,</div><div><br></div><div>Unfortunately, shapefiles do not contain topological information, and in particular, adjacency info; the lines that make up a border are repeated for the two areas it separates. Thus there's not an easy way to readily determine which borders are interior to your outer regions, and which are borders between two outer regions. Since you are drawing the outer regions in distinctly different colors, perhaps just not drawing any edges will suffice?<br></div><div><br></div><div>Rick<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 30, 2019 at 1:33 PM Tabish Ansari <<a href="mailto:tabishumaransari@gmail.com">tabishumaransari@gmail.com</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 dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I'm trying to map three distinct regions, two of which are a collection of several districts, and create boundaries for them on a map. I have shapefiles for each district but drawing polylines using all the member districts would also draw internal boundaries which I don't want. I only want to draw outer boundaries for each region. Please see the attached plot. <br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">My script is pasted here:</div><br><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><i>begin<br>  wks  = gsn_open_wks("png","pulse-districts") ; send graphics to PNG file<br><br>  res                     = True<br>  res@gsnDraw             = False       ; don't draw yet<br>  res@gsnFrame            = False       ; don't advance frame yet<br>  res@gsnMaximize         = True       ; maximize plot in frame<br>;  res@gsnPaperOrientation = "portrait"<br>  res@vpKeepAspect        = True  <br>  res@mpProjection        = "LambertConformal"    ; choose projection<br>  res@mpLambertParallel1F = 20          ; first parallel<br>  res@mpLambertParallel2F = 50          ; second parallel<br>  res@mpLambertMeridianF  = 110         ; meridian<br><br>  res@mpLimitMode         = "Corners"   ; corner method of zoom<br>  res@mpLeftCornerLatF  = 35<br>  res@mpLeftCornerLonF  = 109.35<br>  res@mpRightCornerLatF = 44.41<br>  res@mpRightCornerLonF = 124.94<br><br>  res@pmTickMarkDisplayMode = "Always"  ; turn on tickmarks<br>  res@tmXBMajorOutwardLengthF = 0.0<br>  res@tmXTMajorOutwardLengthF = 0.0<br>  res@tmYLMajorOutwardLengthF = 0.0<br>  res@tmYRMajorOutwardLengthF = 0.0<br><br>   res@tiMainFontHeightF  = 0.025<br>  res@tiYAxisFontHeightF = 0.01<br>  res@tiXAxisFontHeightF = 0.01<br>  res@tmXBLabelFontHeightF = 0.01<br>  plot = gsn_csm_map(wks,res)   ; Create map, but don't draw it yet.<br><br>;*************************************************<br>; Section to add polygons to map.<br>;*************************************************<br>  f = addfile("/home/tabish/Shapefiles/China/CHN_adm2.shp", "r")   ; Open shapefile<br>  <br>;<br>; Read data off shapefile<br>;<br>  segments = f->segments<br>  geometry = f->geometry<br>  segsDims = dimsizes(segments)<br>  geomDims = dimsizes(geometry)<br>;<br>; Read global attributes  <br>;<br>  geom_segIndex = f@geom_segIndex<br>  geom_numSegs  = f@geom_numSegs<br>  segs_xyzIndex = f@segs_xyzIndex<br>  segs_numPnts  = f@segs_numPnts<br><br>  lines       = new(segsDims(0),graphic)   ; Array to hold polygons<br>  numFeatures = geomDims(0)<br><br>  name =  f->NAME_2<br>  lon   = f->x<br>  lat   = f->y<br><br>  plres             = True       ; resources for polylines<br>  plres@gsEdgesOn   = True       ; draw border around polygons<br>  plres@gsEdgeColor = "grey"    <br>;  plres@gsFillColor      = "Navy"<br>;  plres@gsFillOpacityF    = 0.5<br>  <br>  segNum = 0<br>  do i=0, numFeatures-1  <br><br>     ; color assignment (probably a better way to do this?)<br>     if (name(i).eq."Beijing") then<br>        plres@gsFillColor = "tomato"<br>    <br>     else if (name(i).eq."Langfang").or.(name(i).eq."Baoding").or.(name(i).eq."Shijiazhuang").or.(name(i).eq."Xingtai").or.(name(i).eq."Handan").or.(name(i).eq."Tangshan").or.(name(i).eq."Tianjin").or.(name(i).eq."Cangzhou").or.(name(i).eq."Hengshui").or.(name(i).eq."Dezhou").or.(name(i).eq."Binzhou").or.(name(i).eq."Dongying").or.(name(i).eq."Liaocheng").or.(name(i).eq."Jinan").or.(name(i).eq."Zibo")then<br>        plres@gsFillColor = "limegreen"<br>     <br>     else         <br>        plres@gsFillColor = "dodgerblue"<br>     end if<br>     end if<br><br>     startSegment = geometry(i, geom_segIndex)<br>     numSegments  = geometry(i, geom_numSegs)<br>     do seg=startSegment, startSegment+numSegments-1<br>        startPT = segments(seg, segs_xyzIndex)<br>        endPT = startPT + segments(seg, segs_numPnts) - 1<br>        lines(segNum) = gsn_add_polygon(wks, plot, lon(startPT:endPT),  \<br>                                                   lat(startPT:endPT), plres)<br>        segNum = segNum + 1<br>     end do<br>    plres@gsFillColor      = "Grey" <br> end do<br><br>print("done making polygons")<br><br>delete(lat)<br>delete(lon)<br><br>;---Attach some dummy text strings<br>  txres               = True<br>  txres@txFontHeightF = 0.020<br>  txres@txJust        = "CenterCenter"<br><br>;STARTING TO MARK CITIES WHERE APEC CONTROLS WERE IMPLEMENTED<br>lat=40.15<br>lon=116.4074<br>text = "Beijing"<br>text_id1 = gsn_add_text(wks,plot,text,lon,lat,txres)<br><br>lat=38<br>lon=116.2<br>text = "Near Neighbourhood"<br>text_id8 = gsn_add_text(wks,plot,text,lon,lat,txres)<br><br>lat=41<br>lon=112.2<br>text = "Far Neighbourhood"<br>text_id8 = gsn_add_text(wks,plot,text,lon,lat,txres)<br><br>; Maximize output in frame. This will draw everything and advance<br>; the frame.<br>;<br>  maximize_output(wks,False)<br><br>end</i></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thanks very much.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Cheers,</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Tabish<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div><div dir="ltr" class="gmail-m_4668503688745599428gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></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="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>