Hi all,
I am trying to take lat/lon data I have for rainfall and plot these on a map as scatter points via polymarkers (or polygons) that are shaded (or filled) with the corresponding rainfall values to a predefined NCL color map (in this case converting WhiteYellowOrangeRed rgb to cmap).
I have looked at the polygon climate division example script and figured that the function GetFillColor would be my best option and to follow this script. However, I do not have input polygons for the locations as the example has (only lat lon values) and I am having problems drawing "dummy" square polygons to then fill in. Below is what I have but that currently does not work properly. Any help would be greatly appreciated. Thanks!
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/csm/contributed.ncl"
;***************************************************
begin
;***************************************************
;the data in pre(lat,lon,value) 3D
cont_data=asciiread("/sffiles/mmarcella/SEAM_wetexp/cont/FloodZip_onestorm_cont.txt",(/96,3/),"float")
;or separated 1D arrays
cont_lat = cont_data(:,0)
cont_lon = cont_data(:,1)
cont_loss= cont_data(:,2)
;-------------------------- plot stuff ---------------------------
wks = gsn_open_wks ("pdf","loss_polyg")
; resources for the plot
res=True
; map resources for projection
res@mpLimitMode<mailto:res@mpLimitMode> = "LatLon"
res@mpMinLatF<mailto:res@mpMinLatF> = 04.0 ; map area
res@mpMaxLatF<mailto:res@mpMaxLatF> = 24.0 ; latitudes
res@mpMinLonF<mailto:res@mpMinLonF> = 115.0 ; and
res@mpMaxLonF<mailto:res@mpMaxLonF> = 135.0 ; longitudes
; map resources
;res@mpDataBaseVersion = "Ncarg4_1"
res@mpFillOn<mailto:res@mpFillOn> = True
res@mpGridAndLimbOn<mailto:res@mpGridAndLimbOn> = False
; polygon resources
res_poly = True
res_poly@gsEdgesOn<mailto:res_poly@gsEdgesOn> = True ; draw border around polygons
res_poly@gsEdgeColor<mailto:res_poly@gsEdgeColor> = "black"
res@mpFillOn<mailto:res@mpFillOn> = False
res@mpPerimOn<mailto:res@mpPerimOn> = False
res@mpGridAndLimbOn<mailto:res@mpGridAndLimbOn> = False
res@gsnDraw<mailto:res@gsnDraw> = False ; don't draw the plots now
res@gsnFrame<mailto:res@gsnFrame> = False ; or advance the frame
;converting rgb to colormap
cmap = RGBtoCmap ("WhiteYellowOrangeRed.rgb")
gsn_define_colormap (wks,cmap)
plot = gsn_map(wks,"Mercator",res)
;-------------------------------------------------------------------
; plot color coded climate division annual mean total precipitation
; for each of the polygons
;-------------------------------------------------------------------
; contour levels
cnLevels = ispan(1,100,2)
; get correct color to fill polygon
do i=0,cont_size-1,1
res_poly@gsFillColor<mailto:res_poly@gsFillColor> = GetFillColor(cnLevels,cmap,cont_loss(i))
gsn_polygon (wks,plot,cont_poly_x,cont_poly_y,res_poly)
end do
draw(plot)
frame(wks)
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 4 21:24:08 2013
This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:58 MDT