[ncl-talk] problem to plot raster mode

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Wed Jul 17 14:52:39 MDT 2019


You can get the highest quality plot without regridding, if you can get a
different shapefile that includes all of the areas surrounding your basin.
Do not use the data mask function.  Make a filled contour plot over the
entire area, then cover the unwanted ares in white.  See plot #3 of example
shapefiles_21:
https://www.ncl.ucar.edu/Applications/Images/shapefiles_21_3_lg.png

We talked about this last February for a different shapefile.  For more
suggestions, see that conversation:
http://mailman.ucar.edu/pipermail/ncl-talk/2019-February/014178.html


On Wed, Jul 17, 2019 at 10:55 AM Adam Phillips via ncl-talk <
ncl-talk at ucar.edu> wrote:

> 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
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190717/382f989a/attachment.html>


More information about the ncl-talk mailing list