<div dir="ltr"><div><div><div><div>Hi Grace, <br><br></div>The error suggests that the two support files that accompany a shapefile are missing -- in addition to the &quot;*.shp&quot; file, there needs to be a &quot;*.shx&quot; and a &quot;*.dbf&quot; files in the same directory with the same name prefix. Do you have those?  If so, and you are still getting an error, can you send me your shapefiles that are failing?<br><br></div>As a general comment, the word &quot;shapefile&quot; is unfortunate and causes confusion; to the user, it appears as though its just the one file, ie., the &quot;*.shp&quot; file . It is really a collection of up to 5-6 files, 3 of which (shp/shx/dbf) are critical. <br><br></div>Hope that helps...<br></div>Rick<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 3, 2015 at 12:08 AM, grace <span dir="ltr">&lt;<a href="mailto:313695096@qq.com" target="_blank">313695096@qq.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<div>Hi all:</div>
<div>   I am trying to plot precipitation with wrfout data and try to add .shp on the <font color="#006091">plot.</font></div>
<div><font color="#006091">But error happened:</font></div>
<div>ERROR 4: Unable to open /public/home/huanglei/map/shaanxi_diqu.shx or /public/home/huanglei/map/shaanxi_diqu.SHX.<br>fatal:Failed to open OGR file: <br>fatal:/public/home/huanglei/map/shaanxi_diqu.shp<br>fatal:Could not open (/public/home/huanglei/map/shaanxi_diqu.shp)</div>
<div>I have changed different shp file,but the errors are same.<br>My NCL version is 6.2.0.</div>
<div> How can I slove the problem?</div>
<div>
<div><span style="LINE-HEIGHT:24px"><font style="LINE-HEIGHT:30px" size="2"> <font size="4">  </font></font></span><span style="LINE-HEIGHT:24px"><font size="4">   This is my script:</font></span></div>
<div><span style="LINE-HEIGHT:24px">;   Example script to produce plots for a WRF real-data run,<br>;   with the ARW coordinate dynamics option.</span></div>
<div><span style="LINE-HEIGHT:24px">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot; <br>begin<br>;<br>; The WRF ARW input file.  <br>; This needs to have a &quot;.nc&quot; appended, so just do it.<br>  a = addfile(&quot;/public/home/huanglei/wrfdata/5km/wrfout_d03_2015-08-02_12:00:<a href="http://00.nc" target="_blank">00.nc</a>&quot;,&quot;r&quot;)</span></div>
<div><span style="LINE-HEIGHT:24px">; We generate plots, but what kind do we prefer?<br> ; type = &quot;x11&quot;<br> type = &quot;pdf&quot;<br>; type = &quot;ps&quot;<br>; type = &quot;ncgm&quot;<br>  wks = gsn_open_wks(type,&quot;plt_Precip_5km0802&quot;)</span></div><span style="LINE-HEIGHT:24px">
<div><br>; Set some basic resources<br>  res = True<br>  <a href="mailto:res@MainTitle" target="_blank">res@MainTitle</a> = &quot;REAL-TIME WRF&quot;</div>
<div>  mpres  = True  ; Map resources<br>  <a href="mailto:mpres@mpOutlineOn" target="_blank">mpres@mpOutlineOn</a> = False  ; Turn off map outlines<br>  <a href="mailto:mpres@mpFillOn" target="_blank">mpres@mpFillOn</a>    = False  ; Turn off map fill<br>  <a href="mailto:mpres@mpGridAndLimbOn" target="_blank">mpres@mpGridAndLimbOn</a> = True<br> ;res@mpProjection          = &quot;Lambert&quot;<br>  pltres = True ; Plot resources<br>  <a href="mailto:pltres@PanelPlot" target="_blank">pltres@PanelPlot</a>  = True   ; Tells wrf_map_overlays not to remove overlays</div>
<div><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div>; What times and how many time steps are in the data set?<br>  FirstTime = True<br>  times = wrf_user_getvar(a,&quot;times&quot;,-1)  ; get all times in the file<br>  ntimes = dimsizes(times)         ; number of times in the file</div>
<div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div>  do it = 0,24,3            ; TIME LOOP</div>
<div>    print(&quot;Working on time: &quot; + times(it) )<br>    <a href="mailto:res@TimeLabel" target="_blank">res@TimeLabel</a> = times(it)   ; Set Valid time to use on plots</div>
<div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>; First get the variables we will need        </div>
<div><br>  ; Get non-convective, convective and total precipitation of 5km                          <br>    rain_exp = wrf_user_getvar(a,&quot;RAINNC&quot;,it)<br>    rain_con = wrf_user_getvar(a,&quot;RAINC&quot;,it)<br>    rain_tot = rain_exp + rain_con<br>    <a href="mailto:rain_tot@description" target="_blank">rain_tot@description</a> = &quot;Total Precipitation&quot;</div>
<div><br> ;calculate the precipitation <br>      if ( it .eq. 0 ) then<br>        rain_exp_save = rain_exp<br>        rain_con_save = rain_con<br>        rain_tot_save = rain_tot</div>
<div>      else<br>        rain_exp_save = wrf_user_getvar(a,&quot;RAINNC&quot;,it-1)<br>        rain_con_save = wrf_user_getvar(a,&quot;RAINC&quot;,it-1)<br>        rain_tot_save = rain_exp_save + rain_con_save</div>
<div><br>        times_sav = times(it-1)<br>      end if<br>    rain_tot_tend = rain_tot - rain_tot_save</div>
<div>    <a href="mailto:rain_tot_tend@description" target="_blank">rain_tot_tend@description</a> = &quot;Precipitation of 5km&quot;</div>
<div>  ; Bookkeeping, just to allow the tendency at the next time step<br>    rain_exp_save = rain_exp<br>    rain_con_save = rain_con<br>    rain_tot_save = rain_tot</div>
<div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div><br>      ; Plotting options for Precipitation<br>        opts_r = res                        <br>        <a href="mailto:opts_r@UnitLabel" target="_blank">opts_r@UnitLabel</a>            = &quot;mm&quot;<br>        <a href="mailto:opts_r@cnLevelSelectionMode" target="_blank">opts_r@cnLevelSelectionMode</a> = &quot;ExplicitLevels&quot;<br>        <a href="mailto:opts_r@cnLevels" target="_blank">opts_r@cnLevels</a>             = (/ .1, .2, .4, .8, 1.6, 3.2, 6.4, \<br>                                        12.8, 25.6, 51.2, 102.4/)<br>        <a href="mailto:opts_r@cnFillColors" target="_blank">opts_r@cnFillColors</a>         = (/&quot;White&quot;,&quot;White&quot;,&quot;DarkOliveGreen1&quot;, \<br>                                        &quot;DarkOliveGreen3&quot;,&quot;Chartreuse&quot;, \<br>                                        &quot;Chartreuse3&quot;,&quot;Green&quot;,&quot;ForestGreen&quot;, \<br>                                        &quot;Yellow&quot;,&quot;Orange&quot;,&quot;Red&quot;,&quot;Violet&quot;/)<br>        <a href="mailto:opts_r@cnInfoLabelOn" target="_blank">opts_r@cnInfoLabelOn</a>        = False<br>        <a href="mailto:opts_r@cnConstFLabelOn" target="_blank">opts_r@cnConstFLabelOn</a>      = False<br>        <a href="mailto:opts_r@cnFillOn" target="_blank">opts_r@cnFillOn</a>             = True<br>    <br>        <a href="mailto:opts_r@gsnDraw" target="_blank">opts_r@gsnDraw</a>      =  False                  <br>        <a href="mailto:opts_r@gsnFrame" target="_blank">opts_r@gsnFrame</a>     =  False<br>    <br>      ; Precipitation Tendencies<br>       if(it .gt. 0)then <br>        <a href="mailto:opts_r@SubFieldTitle" target="_blank">opts_r@SubFieldTitle</a> = &quot;from &quot; + times(it-3) + &quot; to &quot; + times(it)<br>    end if<br>        contour_tend = wrf_contour(a,wks, rain_tot_tend,opts_r) ; total (color)</div>
<div>        delete(opts_r)</div>
<div> </div>
<div>      ; MAKE PLOTS                                       <br>         plot = wrf_map_overlays(a,wks,contour_tend,pltres,mpres)</div>
<div><br>  <br>;&gt;============================================================&lt;<br>;                      add China map<br>;&gt;------------------------------------------------------------&lt;</div>
<div>     <br>  shp_name1    = &quot;/public/home/huanglei/map/shaanxi_diqu.shp&quot;</div>
<div>  lnres                  = True<br>  <a href="mailto:lnres@gsLineColor" target="_blank">lnres@gsLineColor</a>      = &quot;gray25&quot;<br>  <a href="mailto:lnres@gsLineThicknessF" target="_blank">lnres@gsLineThicknessF</a> = 0.5   </div>
<div> id = gsn_add_shapefile_polylines(wks,plot,shp_name1,lnres)<br> ; shp_name2    = &quot;/home/huanglei/map/China/cnmap/cnhimap.shp&quot;</div>
<div>;  prres=True<br> ; <a href="mailto:prres@gsLineThicknessF" target="_blank">prres@gsLineThicknessF</a> = 2.0       <br>;  <a href="mailto:prres@gsLineColor" target="_blank">prres@gsLineColor</a> = &quot;black&quot;<br> ; plotcn3 = gsn_add_shapefile_polylines(wks,plot,shp_name2,prres)<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div> draw(plot)       ; This will draw the map and the shapefile outlines.<br>  frame(wks)<br>  end do        ; END OF TIME LOOP</div>
<div>end<br></div></span></div></div><br>_______________________________________________<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/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>