[ncl-talk] extract_data_in columnar_wise

Mary Haley haley at ucar.edu
Tue Mar 7 09:45:43 MST 2017


Kunal,

You can use the gc_inout function, in which you give it a series of lat/lon
pairs and a lat/lon polygon, and it returns True or False for each lat/lon
pair, depending on whether it is inside or outside the polygon.

http://www.ncl.ucar.edu/Document/Functions/Built-in/gc_inout.shtml

You will need to turn your data's lat/lon locations into 1D arrays of
lat/lon pairs for this to work.

I've attached an example that shows how to do this for data that is
rectilinear (i.e. you have lat / lon coordinate arrays attached to the data
variable).

This example writes the new data values to a file called "file.txt" and it
also creates some plots of the original data and masked data.

I will likely turn this example into a new one on the "Masking" example
page:

http://www.ncl.ucar.edu/Applications/mask.shtml

--Mary




On Tue, Mar 7, 2017 at 12:01 AM, Kunal Bali <kunal.bali9 at gmail.com> wrote:

> Dear NCL users,
>
> I need to extract the data from the given box in 3 columns (lat, lon,
> values)
>
> could anyone please provide some information on that?
>
> the black box coordinates are as
>
>   lonv = (/77.98,77.96,79.01,80.02,80.01,79.64,79.63,79.01,77.98/)
>
>   latv = (/31.00,29.70,29.15,28.82,30.05,30.01,30.61,30.64,31.00/)
>
> Thank You
>
>
>>
> Regards
> Kunal Bali
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> 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/20170307/30c32530/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.png
Type: image/png
Size: 227806 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170307/30c32530/attachment-0004.png 
-------------- next part --------------
   lat     lon    data
  29.10   79.41   0.025
  29.10   79.72   0.022
  29.31   78.79   0.036
  29.31   79.10   0.033
  29.31   79.41   0.027
  29.31   79.72   0.022
  29.52   78.48   0.040
  29.52   78.79   0.040
  29.52   79.10   0.035
  29.52   79.41   0.028
  29.52   79.72   0.022
  29.72   78.17   0.039
  29.72   78.48   0.040
  29.72   78.79   0.038
  29.72   79.10   0.033
  29.72   79.41   0.028
  29.72   79.72   0.023
  29.93   78.17   0.034
  29.93   78.48   0.032
  29.93   78.79   0.030
  29.93   79.10   0.027
  29.93   79.41   0.025
  29.93   79.72   0.024
  30.14   78.17   0.023
  30.14   78.48   0.020
  30.14   78.79   0.018
  30.14   79.10   0.019
  30.14   79.41   0.022
  30.34   78.17   0.011
  30.34   78.48   0.006
  30.34   78.79   0.007
  30.34   79.10   0.012
  30.34   79.41   0.018
  30.55   78.17   0.001
  30.55   78.48  -0.003
  30.55   78.79  -0.001
  30.55   79.10   0.006
  30.55   79.41   0.014
  30.76   78.17  -0.004
  30.76   78.48  -0.007
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mask_data.000002.png
Type: image/png
Size: 162129 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170307/30c32530/attachment-0005.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mask_data.000003.png
Type: image/png
Size: 149002 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170307/30c32530/attachment-0006.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mask_data.000001.png
Type: image/png
Size: 72262 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170307/30c32530/attachment-0007.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mask_data_latlon_polygon.ncl
Type: application/octet-stream
Size: 6121 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170307/30c32530/attachment-0001.obj 


More information about the ncl-talk mailing list