Re: [ncarg-talk] [ncl-talk] drawing polymarkers/gons shaded by corresponding scalar field

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 06 2013 - 13:20:38 MDT

Hi Marc,

Instead of using gsn_polygon, you can try gsn_polymarker.

See example polyg_8.ncl at:

http://www.ncl.ucar.edu/Applications/polyg.shtml

This uses dummy data, but it shows how to draw markers with different sizes and colors, depend on the range of data they fall in.

--Mary

On Jun 4, 2013, at 9:23 PM, Marc Pace Marcella wrote:

> 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 = "LatLon"
> res@mpMinLatF = 04.0 ; map area
> res@mpMaxLatF = 24.0 ; latitudes
> res@mpMinLonF = 115.0 ; and
> res@mpMaxLonF = 135.0 ; longitudes
>
> ; map resources
> ;res@mpDataBaseVersion = "Ncarg4_1"
> res@mpFillOn = True
> res@mpGridAndLimbOn = False
>
> ; polygon resources
> res_poly = True
> res_poly@gsEdgesOn = True ; draw border around polygons
> res_poly@gsEdgeColor = "black"
>
> res@mpFillOn = False
> res@mpPerimOn = False
> res@mpGridAndLimbOn = False
>
> res@gsnDraw = False ; don't draw the plots now
> 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 = 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

_______________________________________________
ncarg-talk mailing list
ncarg-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncarg-talk
Received on Thu Jun 6 13:20:57 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:58 MDT