[ncl-talk] Questions About Shapefiles

Mary Haley haley at ucar.edu
Fri Oct 31 11:08:17 MDT 2014


Dear Ce Zhu,

The issue may simply be that your original data doesn't contain any grid
points that are close to the boundary you gave it.

NCL is not going to create contours outside of your non-missing values,
and, if there's a single "good" point surrounded on all four sides by
missing values, then that single point will not have any contours on it.

You can see an example of this with the attached script called
"mask_example.ncl".

I've created both a "coarse" (lower resolution) and "fine" (higher
resolution) version of a dummy lat/lon grid. I masked this grid using
outlines from the "mrb.shp" file and called "gsn_coordinates" to draw the
locations of the lat/lon grid as tiny dots.

Note that in the "coarser.png" image, the south part of the shapefile
outline doesn't have any contours in the mask data image. This is because
the "good" points in that part of the outline are single points, surrounded
by missing points. Look around the rest of the red shapefile outline, and
you will see that the color contours do not go all the way to the edge.
This is simply because the grid is too coarse.

In the "finer.png" image, the south part has at least three points in a row
that fall inside the boundary, and you will see contours in that area.

If you want to get points close to the edge of your shapefile outlines, and
also include points just outside the outline, then you can try masking your
data against a rectangle box that encloses the shapefile outline, with an
extra "margin" to enclose a few points outside.  This may give you more
points than you want.  See the attached "mask_example_rectangle.ncl" file
and the "coarser_rect.png" image.

--Mary

On Fri, Oct 31, 2014 at 7:17 AM, Zhu CE <lovingzhuce at 163.com> wrote:

> Dear NCL users,
>
> Recently I am trying to use the shapefiles downloaded from DIVA-GIS (
> http://www.diva-gis.org/gdata) <http://www.diva-gis.org/gdata),>. Those
> files can provide finer boundary information (like Nanjing City in Jiangsu
> Province, China) than Earth..3
> <http://www.ncl.ucar.edu/Document/HLUs/Classes/MapPlotData4_1_earth_3.shtml> database
> provides.
> I have known how to plot shapefiles and shapefiles_4.ncl
> <http://www.ncl.ucar.edu/Applications/Scripts/shapefiles_4.ncl> also
> shows an example of masking out all areas inside or outside this
> outline.But the masking results are coarser and slower than masking doing
> by NCL itself.
> I am writing to ask are there some alternative methods to mask area out
> finer and quicker with shapefiles or to add shapefile information into map database
> like Earth..3
> <http://www.ncl.ucar.edu/Document/HLUs/Classes/MapPlotData4_1_earth_3.shtml>?
> Could you help me? Thanks a lot.
> Attached is the masked plot using shapefiles_4.ncl
> <http://www.ncl.ucar.edu/Applications/Scripts/shapefiles_4.ncl> script.
>
> Best wishes,
>
> Ce Zhu
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20141031/5774b609/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ??1.png
Type: image/png
Size: 93206 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141031/5774b609/attachment-0004.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mask_example.ncl
Type: application/octet-stream
Size: 3951 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141031/5774b609/attachment-0003.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shapefile_mask_data.ncl
Type: application/octet-stream
Size: 13478 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141031/5774b609/attachment-0004.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coarser_rect.png
Type: image/png
Size: 306629 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141031/5774b609/attachment-0005.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mask_example_rectangle.ncl
Type: application/octet-stream
Size: 8757 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141031/5774b609/attachment-0005.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coarser.png
Type: image/png
Size: 294159 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141031/5774b609/attachment-0006.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: finer.png
Type: image/png
Size: 531015 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141031/5774b609/attachment-0007.png 


More information about the ncl-talk mailing list