[ncl-talk] adding polygons/markers to map only

Dennis Shea shea at ucar.edu
Thu Feb 20 17:55:25 MST 2020


The *gsn_polygon *
<http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_polygon.shtml>procedure
allows you to enter arrays

 gsn_polygon(wks, plot, xlon , ylat , gspoly)    ; will plot all values
with one call
 gsn_polygon(wks, plot, xlonr, ylatr, gspoly)

I have no ideq what the difference between xlon and xlonr is.

The same for *gsn_text*
<http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_text.shtml>

 gsn_text(wks, plot, city, xlon , ylat , gstxt)    ; will plot all values
with one call

*You* will likely have to add some location offset so text and circle do
not overlap.
===
If for some reason you want to loop.

  nloc = dimsizes(xlon)

  ncity = dimsizes(city)

  do n=0,nloc-1
       gsn_polygon(wks, plot, xlon(n) , ylat(n) , gsres)
       gsn_text(wks, plot, city(n), xlon(n) , ylat(n) , gstxt)
   end do

Good luck


On Thu, Feb 20, 2020 at 5:00 AM Sri.durgesh Nandini-Weiss via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Hello dear NCL users,
>
> I wonder if some one can help me with this script, i am trying to plot a
> map only with some circles around specific lat:lon, e.g. london.
> Somewhat close to ncl example: poly_8_lbar.ncl
>
> I am also attaching the figure i want to get as well as my script.
>
>
> ;==============================================================
> ; Open the file: Read only the user specified period
> ; =============================================================
>
> ; =============================================================
> ; Extracting selected cities
> ; =============================================================
>
>
> ylat=(/  48.,  38.,  34.,  -1.,  -8., -10., -30., -45., -24., -13.,
> -14.,  24.,\
>           22.,  29.,  37.,  41.,  51.,  44.,  65.,  36.,  14., 9.,
> 6.,  -9.,\
>          -38., -30.,  -7.,  24.,  22.,  22.,  13., -13.,  18., 31.,
> 39.,  45.,\
>          -34., -39.,-55./)
>
> xlon=(/-125.,-123.,-119., -81., -79., -80., -71., -57., -46., -38.,
> -38., -82.,\
>          -80., -90., -76., -74., -71., -70.,   1.,  -2., -30., -14.,
> 3.,  13.,\
>           19.,  31.,  40.,  67.,  68.,  91., 100., 107., 114., 122.,
> 122., 145.,\
>          153., 145.,-140./)
>
> ylatr=(/ 48.,  37.8,  34.,  -1.,  -8.2, -12.2, -30., -35., -24., -13.2,
> -3.6,  23.5,\
>           25.7,  29.,  36.8,  41.,  42.4,  44.,  51.5,  38.5, 14.5,
> 9.,   6.,  -9.,\
>          -34.3, -30.,  -7.,  24.,  18.7,  22.,  13., -5.2,  22., 31.,
> 39.,  38.7,\
>          -34.4, -39.,-55./)
>
> xlonr=(/-125.,-123.,-119., -81., -79., -77., -71.5, -57., -46., -38.2,
> -38.3, -82.2,\
>          -80., -90., -76., -74., -71., -70.,   1.,  -9.4, -17.6, -14.,
> 3.,  13.,\
>           18.5,  31.4,  40.,  67.,  72.5,  91., 100., 107., 114.4, 122.,
> 122., 139.7,\
>          152.6, 145.,-140./)
>
> city=(/"Vancouver","San Francisco","Los
> Angeles","Manta","Trujillo","Lima",\
>         "Gran La Serena","Buenos Aires","Sao
> Paulo","Salvado","Fortaleza","Havana",\
>         "Miami","New Orleans","Virginia Beach","New
> York","Boston","Portland",\
>         "London","Lisbon","Dakar","Conakry","Lagos","Luanda","Cape
> Town","Durban",\
>         "Dar es Salaam","Gadap
> Town","Mumbai","Chittagong","Bangkok","Jakarta",\
>         "Hong
> Kong","Shanghai","Dalian","Tokyo","Sydney","Melbourne","Global mean"/)
>
> ;==================================================================
> ;  Here is a section of my code that draws a color fill plot
> ;====================================================================
>
>    wks = gsn_open_wks("pdf","map_cities")
>    res = True
>    res at cnFillOn            = True                ; turn on color
>
>    res at gsnFrame            = False           ; don't advance frame
>    res at cnInfoLabelOn       = False           ; turn off cn info label
>    res at cnFillOn            = True            ; turn on color
>
>    res at mpDataBaseVersion   = "MediumRes"
>    res at cnLinesOn           = False
>
>    res at mpCenterLonF = 30.
>
>    res at mpOutlineOn            = True
>    res at mpPerimOn              = False
>    res at gsnMaximize            = True              ; large format in
> landscape
>
>    res at mpLandFillColor        = "tan"
>    res at mpOceanFillColor       = "LightBlue"
>    res at mpInlandWaterFillColor = "Blue"
>
> At this point, it of course plots a standard map only, but i haven't
> figured out how to loop in the polygons based on the lat and lon of my
> selected cities gridpoints.
>
> I wonder if someone can help me code the remainder bit of it?
>
> Would be really grateful!
>
> Sri
>
>
> --
> Dr. Sri Nandini-Weiß
> Research Scientist
>
> Universität Hamburg
> Center for Earth System Research and Sustainability (CEN)
> Cluster of Excellence 'Climate, Climatic Change, and Society' (CLICCS)
>
> Bundesstrasse 53, 20146 Hamburg
> Tel: +49 (0) 40 42838 7472
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200220/c205f86f/attachment.html>


More information about the ncl-talk mailing list