[ncl-talk] Shapefile doubt

Jesús Garcia Rosales jesus21gr at gmail.com
Mon May 23 11:02:13 MDT 2016


Hi everybody
I have a doubt about a shapefile in ncl. I want to plot only a part of the
shapefile which  is inside in the circle red. But I don't know how to do
that. Please help me.
Greetings,
Alan

My script is the next:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"

begin


year= "exp_re"


;---Open WRF output file.

a =
addfile("/media/usuario/TOSHIBA/WRF_alan/9km/exp_re/wrfout_2002F."+year+".
3km.nc","r")

;---Read terrain height and lat/lon off file.
  it        = 0     ; first time step
  hgt       = wrf_user_getvar(a,"HGT",it)    ; Terrain elevation
  hgt at lat2d = wrf_user_getvar(a,"XLAT",it)   ; latitude/longitude
  hgt at lon2d = wrf_user_getvar(a,"XLONG",it)  ; required for plotting

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Grafico
;;;;;;;;;;;;; Salida
 type = "x11"
; type = "pdf"
 ;type = "ps"
; type = "ncgm"


  wks = gsn_open_wks(type,"graficas/topografia_cuenca_estaciones")

;---Set some basic plot options
  res               = True

  res at gsnMaximize   = True   ; maximize plot in frame
  res at gsnDraw       = False
  res at gsnFrame      = False

 ; res at tiMainString  = filename

  res at cnFillOn      = True
  res at cnFillPalette = "OceanLakeLandSnow"
  res at cnLinesOn     = False

  res at mpProjection  = "CylindricalEquidistant"    ; The default

;---Zoom in on plot
  res at mpMinLatF     = -13.8
  res at mpMaxLatF     = -10.5
  res at mpMinLonF     = -77
  res at mpMaxLonF     = -73.6

;---Additional resources desired
  res at pmTickMarkDisplayMode = "Always"   ; nicer tickmarks

  res at mpDataBaseVersion     = "MediumRes"       ; better and more map
outlines
  res at mpDataSetName         = "Earth..4"
  res at mpOutlineBoundarySets = "AllBoundaries"
  res at mpOutlineOn           = True

  res at lbOrientation         = "Vertical"
  res at tiMainOffsetYF        = -0.03           ; Move the title down

;---Change contour levels to better match the color map being used
  res at cnLevelSelectionMode = "ExplicitLevels"
  res at cnLevels = (/10,100,200,400,600,800,1000,1200,1400,1600,1800,2000,\

2200,2400,2800,3000,3200,3400,3600,3800,4000,4200,4400,4600,4800,5000,\
                  5200,5400/)


  res at gsnAddCyclic = False

 plot = gsn_csm_contour_map(wks,hgt,res)

alres = True

  latN = -10.5
  latS = -13.8         ;-13.58
  lonL  = -77
  lonR  = -73.6

  ; Coordenadas de cada estación que se quiere ubicar

  lat=(/-12.04, -10.69, -11.4, -11.33, -12.25, -12.12, -11.4, -11.75,
-11.88, -11.62, \
        -11.78, -12, -12.16, -12.38, -12.35, -12.58, -12.78, -12.98,
-13.06, -12.84/)

  lon=(/-75.32, -76.26, -76.33, -76.4, -75.36, -75.43, -75.69, -75.13,
-75.27, -75.01,\
        -75.47, -75.22, -75.23, -74.85, -75.08, -75.24, -75.01, -74.72,
-74.14, -74.57/)





colors =(/"blue3"/)

 ;colors =
(/"orange2","forestgreen","dodgerblue2","forestgreen","orange2","orange2","forestgreen","dodgerblue2",\
  ;
"dodgerblue2","olivedrab2","forestgreen","orange2","orange2","olivedrab2","darkorchid2","olivedrab2",\
   ;        "forestgreen","darkorchid2","olivedrab2","darkorchid2"/)

; orange2



  labels = (/"Huayao","Cerro de
Pasco","Marcapomacocha","Yantac","Laive","Jarpa","Tarma","Comas"\
           ,"Ingenio","Ricran","Jauja","Santa
Ana","Viques","Pampas","Pilchaca","Huancalpi"\
            ,"Huancavelica","Lircay","Quinua","Acobamba"/)

; Manually specify location of legends

  xleg =
(/0.15,0.15,0.15,0.15,0.15,0.35,0.35,0.35,0.35,0.35,0.56,0.56,0.56,0.56,0.56,0.80,0.80,0.80,0.80,0.80/);
Location of
  xtxt =
(/0.22,0.225,0.225,0.225,0.225,0.44,0.44,0.44,0.44,0.44,0.65,0.66,0.66,0.66,0.66,0.88,0.88,0.88,0.88,0.88/)
 ; legend markers
  yleg =
(/0.20,0.17,0.14,0.11,0.08,0.20,0.17,0.14,0.11,0.08,0.20,0.17,0.14,0.11,0.08,0.20,0.17,0.14,0.11,0.08/)
  ; and text
  ytxt =
(/0.20,0.17,0.14,0.11,0.08,0.20,0.17,0.14,0.11,0.08,0.20,0.17,0.14,0.11,0.08,0.20,0.17,0.14,0.11,0.08/)
 ; strings.

  mkres               = True
  mkres at gsMarkerIndex = 17     ; Filled circle
  mkres at gsMarkerSizeF = 0.05    ;0.03

  txres               = True
  txres at txFontHeightF = 0.014







    mkres at gsMarkerColor = colors
  la=  gsn_add_polymarker(wks,plot,lon(:),lat(:),mkres)

 cuenca_mantaro_shp_name = "/home/usuario/Escritorio/alan/cuencas/UH.shp"

  lnres                  = True
  lnres at gsLineColor      = "black"
  lnres at gsLineThicknessF = 4

 can_id =
gsn_add_shapefile_polylines(wks,plot,cuenca_mantaro_shp_name,lnres)

overlay(la,can_id)




 draw(plot)
 frame(wks)


  end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160523/2c436807/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Imagen1.png
Type: image/png
Size: 1105081 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160523/2c436807/attachment-0001.png 


More information about the ncl-talk mailing list