[ncl-talk] Mask 1D station data with shapefile?

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Mon Jul 24 13:02:33 MDT 2017


Meina,

Thanks for letting me know about the function shapefile_mask_data.  I had
not used this before, and like you, I did not realize that it was also good
for 1-D point data.  That function is the better approach because it is
much simpler than hand crafting the all that geometry code in your own
program.

--Dave


On Mon, Jul 24, 2017 at 12:54 PM, Meina Wang <mnawang at ucdavis.edu> wrote:

> Dear Dave,
>
> Thank you very much for your detailed explanation.  I went though the
> examples for shapefiles and found the function "shapefile_mask_data" to
> filtered out the data outside specific shapefile.  I previously didn't
> realized this function also works for 1D unstructured data as well besides
> gridded 2D data, and it did what you've demonstrated for reading the lat/
> lon from shapefile and determining if each station is within the shapefile.
> So this function worked for my case with no problem.  Thank you very much
> again for your kind reply :)
>
> Best regards,
> Meina
>
> On Mon, Jul 24, 2017 at 11:43 AM, Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
>> Meina,
>>
>> Read the geometry data from the shape file.  The geometry data is
>> essentially a set of one or more polygon outlines in lat/lon coordinates.
>> Now select the polygon that defines your area to mask.  Then use the NCL
>> function gc_inout to determine whether each station is within the masked
>> area.
>>
>> Please see NCL example shapefiles_13 for a demonstration of how to read
>> the geometry and apply polygons to select station point data.  That is a
>> general example for a shape file containing multiple features and multiple
>> polygons per feature.  If your shape file contains only one feature or one
>> polygon, you can simplify your program and eliminate one or two of the
>> loops from the example.
>>
>>    http://www.ncl.ucar.edu/Applications/shapefiles.shtml
>>
>> --Dave
>>
>>
>> On Sat, Jul 22, 2017 at 11:57 PM, Meina Wang <mnawang at ucdavis.edu> wrote:
>>
>>> Dear NCL users,
>>>
>>> I wanted to use shapefile to mask the station observational data (1D) in
>>> the grey area (sample plot attached below), and would like to pick out the
>>> station data in the grey area (for calculation purpose later).  I'm
>>> wondering if there is a way to do this using shapefile in ncl? Any
>>> suggestion is much appreciated.  Thank you.
>>>
>>> Best,
>>> Meina
>>>
>>
>
>
> --
> Meina Wang
> PhD candidate in Atmospheric Science
> Department of Land, Air and Water Resources
> University of California, Davis
> Davis, CA 95616
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170724/17c1c273/attachment.html 


More information about the ncl-talk mailing list