[ncl-talk] Issue with masking data with shapefile

Amit Kumar amitkumar.777 at hotmail.com
Mon Aug 1 01:13:50 MDT 2016


Hi All,


I'm using NCL 6.1.2 in this i'm trying to mask my data to my shapefile , in order to do so i'm trying to load shapefile_utils.ncl as fatal:Could not open (./shapefile_utils.ncl) . I've downloaded this file from ncl site but Where to keep this file and with what permissions.


how to load this file in ncl as if i'm not loading this file then i get the error shapefile_mask_data () is undefined.


I want to plot data only on my shapefile and mask rest of it.


Please suggest what to do.


load "/usr/share/ncarg/nclscripts/csm/gsn_code.ncl"
load "/usr/share/ncarg/nclscripts/csm/gsn_csm.ncl"
load "/usr/share/ncarg/nclscripts/csm/contributed.ncl"
load "./shapefile_utils.ncl"


begin
 a                 = addfile("/home/amit/Research/3DIMG/Utrakhand_01JUL2016/h5/output/output/3DIMG_30JUN2016_0000_L3B_HEM_DLY_UK.nc","r")

  filename = "/media/amit/E/India_shapefile/Districtbound(Satmet).shp"
  var                 = doubletofloat(a->HEM_DLY(0,:,:))
  lat                 =  a->latitude
  lon                 =  a->longitude

  wks = gsn_open_wks("png","mask")                ; send graphics to PNG file
  res                      = True                  ; plot mods desired
  res at cnFillOn             = True                  ; turn on color fill
  res at cnLinesOn            = False
  res at gsnMaximize          = True     ; maximize plot in frame
  res at gsnDraw              = False
  res at gsnFrame             = False
  res at mpOutlineOn   = False   ; Use outlines from shapefile
  res at mpFillOn      = False
  res at cnLevelSelectionMode = "ExplicitLevels"
  res at cnLevels             = (/0.1,2.5,15.5,64.5,115.5,204.5,400.5,600.5,800.5/) ;   ; 13 contour values
  res at cnFillPalette        = (/"Snow","LightGoldenRodYellow","Yellow"\ ; 13 contour colors
                              ,"Orange","Green","Green4"    \
                              ,"Cyan","Blue2","Blue3","Blue4"/)

  res at tiMainString      = "HEM_DLY_30JUN2016 Maximum :761.31 mm"
  res at tiMainFontHeightF = 0.016
  res at gsnAddCyclic      = False
  res at lbOrientation   = "Vertical"
  res at sfXArray             = lon
  res at sfYArray        =  lat
  res at mpMinLonF             = 78.0
  res at mpMaxLonF             = 81.0
  res at mpMinLatF             = 29.0
res at mpMaxLatF             = 31.0
res at pmTickMarkDisplayMode     = "Always"
res at tiXAxisString            = "Longitude"
res at tiYAxisString            = "Lattitude"
res at tiXAxisFontHeightF         = 0.02
res at tiYAxisFontHeightF         = 0.02
res at gsnStringFontHeightF     = 0.005
plot = gsn_csm_contour_map(wks,var, res)        ; create plot

  opt             = True
  opt at return_mask = True
  shp_mask = shapefile_mask_data(var,filename,opt)

var_shp_mask = where(shp_mask.eq.1,var,var at _FillValue)
copy_VarMeta(var,var_shp_mask)

;---For shapefile plot, use the shapefile outlines.
  res at mpOutlineOn  = False

;---Create plot of original data masked by shapefile outlines
  res at tiMainString = "Original data masked by shapefile outlines"
  var_shp_plot = gsn_csm_contour_map(wks,var_shp_mask,res)
  dum = gsn_add_shapefile_polylines(wks,var_shp_plot,filename,False)
 draw(plot)
 frame(wks)
 end



Regards
Amit Kumar,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160801/f6b9c011/attachment.html 


More information about the ncl-talk mailing list