[ncl-talk] Small issue plotting highways

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Thu Jun 24 14:55:56 MDT 2021


Nick mentioned line thickness.  Yes, I think in the presence of this
unwanted behavior, line thickness has *a lot* to do with it.  With thicker
lines, the distortions may still be present, but will be much less
noticeable.  Try gsLineThicknessF somewhere between 0.5 and 3.0.  This way,
you may be able to keep using PNG format if you need to.


On Thu, Jun 24, 2021 at 8:28 AM Andrew Kren - NOAA Federal via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Thanks. I'm going to try the aliasing, and if that does not work, I'll try
> the vector format. I have seen this issue with and without radar data
> present on the map. Will keep you updated.
>
> On Thu, Jun 24, 2021 at 10:25 AM Rick Brownrigg <brownrig at ucar.edu> wrote:
>
>> wks at wkAntiAlias = "Off"
>>
>> http://ncl.ucar.edu/Document/Graphics/Resources/wk.shtml
>>
>> I'm not sure aliasing is the issue, given your plots with/without radar
>> data present. I would think things should be consistently good or bad. Have
>> you tried a vector format as David suggested? If you need to post to a web
>> page, SVG would be a great option as it scales nicely.
>>
>> Rick
>>
>> On Thu, Jun 24, 2021 at 8:18 AM Andrew Kren - NOAA Federal via ncl-talk <
>> ncl-talk at mailman.ucar.edu> wrote:
>>
>>> Thanks! I tried that but it did not help. on the anti alias feature, how
>>> do I set it? I did not see an example on the ncl documentation pages. I
>>> tried this but it did not work. Thanks.
>>>
>>> wkAntiAlias(wks) = "Off"
>>>
>>> On Thu, Jun 24, 2021 at 9:24 AM Bassill, Nicholas <nbassill at albany.edu>
>>> wrote:
>>>
>>>> The script can be found here:
>>>> https://operations.nysmesonet.org/~nbassill/radar/radar.ncl . As I
>>>> said, there's a lot of (fairly poorly commented) stuff going on there, but
>>>> the most relatable lines for what you're doing are in the middle:
>>>>
>>>>    countyplot := gsn_csm_contour_map(wks2,newdata,resmap)
>>>>
>>>>    pres                 = True
>>>>    pres at gsFillColor     = "transparent"
>>>>    pres at gsFillOpacityF = 0.0
>>>>    pres at gsEdgesOn = True
>>>>    pres at gsLineThicknessF = 8.0
>>>>    pres at gsLineColor= "gray40";"gray30"
>>>>
>>>>  ; if roads.eq."yes"
>>>>    shpid = gsn_add_shapefile_polylines(wks2,countyplot,"tl_2015_36_prisecroads.shp",pres)
>>>>  ; end if
>>>>
>>>> As I mentioned, my line thickness is much greater, though I'm not sure
>>>> if that's the reason.
>>>>
>>>> Nick Bassill, PhD
>>>>
>>>>
>>>>
>>>> *From:* Andrew Kren - NOAA Federal <andrew.kren at noaa.gov>
>>>> *Sent:* Wednesday, June 23, 2021 6:02 PM
>>>>
>>>> Sure go ahead and share if you like.
>>>>
>>>> On Wed, Jun 23, 2021 at 5:21 PM Bassill, Nicholas <nbassill at albany.edu>
>>>> wrote:
>>>>
>>>> Hi Andrew, all,
>>>>    Sort of a shot in the dark here, but coincidentally, I also
>>>> regularly make radar plots and overlay highways (also in gray), along with
>>>> a whole bunch of other info and I have not noticed this with my png files.
>>>> I also use a shapefile for the highways and more or less use your technique
>>>> I think. I'm attaching two examples - one from an active day, and one from
>>>> today just to demonstrate that I always see the same road behavior. I see
>>>> your line thickness is very small - perhaps increasing the thickness would
>>>> help a bit?
>>>>
>>>> If you'd like I'd be happy to share this script, though fair warning it
>>>> has a ton of stuff in so may be a bit hard to parse.
>>>>
>>>> Nick Bassill, PhD
>>>>
>>>>
>>>>
>>>> *From:* ncl-talk <ncl-talk-bounces at mailman.ucar.edu> on behalf of Dave
>>>> Allured - NOAA Affiliate via ncl-talk <ncl-talk at mailman.ucar.edu>
>>>> *Sent:* Wednesday, June 23, 2021 4:52 PM
>>>>
>>>> Andrew, the difference between your plots with and without the contour
>>>> fill layer is surprising.  I can only speculate that there might be a
>>>> branch somewhere inside NCL, that handles antialiasing differently,
>>>> depending on which graphics layers are active.  Notice that the resolution
>>>> of the lettering is also affected slightly.
>>>>
>>>> I still think your best bets are to try the resource suggested by Rick,
>>>> or to avoid the issue by using some form of vector graphics for output.
>>>> Thanks for showing that contrasting plot, and good luck.
>>>>
>>>>
>>>> On Wed, Jun 23, 2021 at 8:08 AM Andrew Kren - NOAA Federal <
>>>> andrew.kren at noaa.gov> wrote:
>>>>
>>>> Thanks Dave and Rick. I will try that. Here is what I get on a day when
>>>> there is nothing on the radar to plot. The highways show up just fine with
>>>> no changes to the code. I'm wondering if it has something to do with the
>>>> contours overlaid or something similar? I will also try a PDF or PS file.
>>>>
>>>>
>>>> On Tue, Jun 22, 2021 at 6:31 PM Dave Allured - NOAA Affiliate <
>>>> dave.allured at noaa.gov> wrote:
>>>>
>>>> Andrew, PNG is an image format that naturally consists of a grid of
>>>> pixels.  The only pixellation that I see in your plot is the natural pixels
>>>> in the PNG format.  Your highways are mostly very fine diagonal lines.  PNG
>>>> decomposes a diagonal line into a group of small gray and black squares
>>>> (pixels) on a regularly spaced pixel grid.  When the intended line is thin
>>>> enough, it is difficult to get a clear representation on the pixel grid.
>>>> One of the possible results is apparently dashed lines like those I am
>>>> seeing.
>>>>
>>>> Try making the same plot using vector graphics such as PDF, postscript
>>>> (PS), or SVG, as Rick suggested.  These vector formats preserve a true
>>>> mathematical representation of line data.  The result is clean edges and
>>>> fine lines that will not pixellate when you zoom in, when using proper
>>>> viewing software that supports true vector mode display.
>>>>
>>>>
>>>> On Tue, Jun 22, 2021 at 12:15 PM Andrew Kren - NOAA Federal via
>>>> ncl-talk <ncl-talk at mailman.ucar.edu> wrote:
>>>>
>>>> Thanks, I'll check it out.
>>>>
>>>> On Tue, Jun 22, 2021 at 11:25 AM Rick Brownrigg <brownrig at ucar.edu>
>>>> wrote:
>>>>
>>>> Hi Andrew,
>>>>
>>>> It's odd that you are getting inconsistent results. Do you see the same
>>>> thing if you write to a PS or PDF file? I don't know what's going on, but
>>>> it looks like a  bit of overzealous anti-aliasing. There's a resource to
>>>> control whether antialiasing is applied or not:
>>>>
>>>> https://www.ncl.ucar.edu/Document/Graphics/Resources/wk.shtml
>>>>
>>>> It's on by default and generally yields better results, but you might
>>>> experiment with it.
>>>>
>>>> Wish I had a better answer.
>>>> Rick
>>>>
>>>>
>>>> On Tue, Jun 22, 2021 at 8:45 AM Andrew Kren - NOAA Federal via ncl-talk
>>>> <ncl-talk at mailman.ucar.edu> wrote:
>>>>
>>>> Hi there,
>>>>
>>>> I am plotting radar data and overlaying highways onto the map. I first
>>>> plot the radar analysis, then overlay the highway information by
>>>> reading/plotting the shapefile.
>>>>
>>>> At times, when I view the PNGs, the highways show up as blotched out
>>>> (lack of detail and pixelated; see attached image). At other times, the
>>>> highways show up very clear and darker as expected. Is there a reason for
>>>> this? Below shows a snippet of my code that produces the radar plot and the
>>>> highway overlay.
>>>>
>>>>  plot = gsn_csm_contour_map(wks,radar,res)
>>>>
>>>>  ; add highway polylines to the map from shapefile
>>>>  plres = True
>>>>  plres at gsLineColor = "grey48"
>>>>  plres at gsLineThicknessF = 0.2
>>>>  id =
>>>> gsn_add_shapefile_polylines(wks,plot,SHAPE_DIR+"roadtrl020.shp",plres)
>>>>
>>>> Thanks,
>>>>
>>>> --
>>>>
>>>> Andrew Kren
>>>> Meteorologist
>>>> NOAA's National Weather Service
>>>> Raleigh Forecast Office
>>>> 1005 Capability Drive, Suite 300
>>>> Raleigh, North Carolina 27606
>>>> voice: 919-326-1035
>>>> mailto: andrew.kren at noaa.govhttp://www.weather.gov/rah
>>>>
>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210624/35569850/attachment.html>


More information about the ncl-talk mailing list