[ncl-talk] problem to plot raster mode

Adam Phillips asphilli at ucar.edu
Wed Jul 17 10:54:45 MDT 2019


Hi Vanúcia,
When you set cnFillMode = "RasterFill", NCL is showing every single grid
box that has data. No interpolation or smoothing is done. The advantage of
this method is that you will see every grid box. The downside is the
block-like appearance. When cnFillMode = "AreaFill" (or if cnFIllMode =
"RasterFill" AND cnSmoothingOn = True), smoothing is done as NCL looks at
values of neighboring grid boxes. However, if not enough neighboring grid
boxes are present, a grid box might not be drawn, and therefore if you have
missing data you may not see all areas that have data filled.

All the above being said, it looks to me like the issue is coming from 1)
the resolution of your data, and 2) the shapefile masking routine is
excluding grid boxes that you do not want excluded. I see two possible
solutions:
1) Interpolate your data to a higher resolution grid, following the
numerous examples on the NCL website. I'd use the ESMF_regrid function.
When the data is masked by the shapefile you should get a more precise
masking on a higher resolution grid. But, note that regridding to a higher
resolution grid is generally not recommended due to the possibility of
adding artifacts that are not there. Compare the regridded and original
grid on a plot to make sure all looks well.
2) Sitck with your current grid, and then add back in points to the array
after the shapefile mask has been applied. This will be tedious, but
looking at the attached plot I created showing the unmasked and masked
grids, it looks to be roughly 10 grid boxes. You will want to
use getind_latlon2d to identify the 2d coordinates needed:
http://www.ncl.ucar.edu/Document/Functions/Contributed/getind_latlon2d.shtml


Hope that helps. I didn't lay out the exact coding needed, but the above
hints should get you started down the right path to solving the issue.
Adam

On Wed, Jul 17, 2019 at 10:10 AM Vanúcia Schumacher via ncl-talk <
ncl-talk at ucar.edu> wrote:

> Using this resource I get the same result if I do not use the RasterFill,
> that is, I do not have full shapefile area filling.
>
> Thank you anyway
> ------------------------------
> *De:* Rick Brownrigg <brownrig at ucar.edu>
> *Enviado:* quarta-feira, 17 de julho de 2019 12:39
> *Para:* Vanúcia Schumacher
> *Cc:* ncl-talk at ucar.edu
> *Assunto:* Re: [ncl-talk] problem to plot raster mode
>
> HI,
>
> With that coarse of resolution of the data, its going to be tough to get a
> really good looking result. You might try using RasterFill and setting the
> resource cnRasterSmoothingOn = True:
>
>
> http://ncl.ucar.edu/Document/Graphics/Resources/cn.shtml#cnRasterSmoothingOn
>
> Rick
>
> On Wed, Jul 17, 2019 at 8:50 AM Vanúcia Schumacher via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
> Hi users,
>
> I'm trying to plot a spatial graph from raster data (mask) using shapefile.
> The problem is that I was able to only plot 34 pixels inside the shapefile
> area, using cnFillMode = "RasterFill".
> However, I would like to not use this command (raster fill) and get a
> spatial graph better defined inside the shapefile, or increase the number
> of pixels within the area shapefile, with a better contour. But I am not
> getting a good result (see figure off_raster).
>
> Attached follows the data and script.
> Thanks any help
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk



-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190717/134dfa3a/attachment.html>


More information about the ncl-talk mailing list