# [ncl-talk] calculate area of polygon box

Kunal Bali kunal.bali9 at gmail.com
Mon Feb 5 10:50:01 MST 2018

```okay, thanks for this suggestion, Adam sir.

I tried

ncl 9> rsph = 6371 *--> to get area in km^2*

ncl 10>  latv =
(/31.00,29.70,29.15,28.82,28.43,28.01,27.98,27.47,27.38,28.64,28.99,29.40,29.56,29.99,30.05,30.01,30.61,30.64,31.00/)
ncl 11> lonv =
(/77.98,77.96,79.01,80.02,80.98,81.57,81.98,83.01,84.00,83.99,83.01,83.01,80.98,81.00,80.01,79.64,79.63,79.01,77.98/)

ncl 12> qarea_poly = area_poly_sphere(latv, lonv, rsph)

ncl 13> print ("qarea_poly="+qarea_poly)

(0) *qarea_poly=5.0997e+08   ---> the calculated area is very large. it
seems like wrong.*

*I mean from figure (previous mail), the longitude ranges from 78 to 84 = 6
degree = ~660 km *
*
latitude rages almost 1 degree = 110 km*
*                                                                  so it
could be 660 x 110 = ~72600 km^2 and from the above function it's *
*5.0997e+08*

---
Kunal Bali

On Mon, Feb 5, 2018 at 10:16 PM, Adam Phillips <asphilli at ucar.edu> wrote:

> Hi Kunal,
> The examples shown on the area_poly_sphere documentation page also
> illustrate how to use gc_clkwise and gc_qarea, the latter having the
> requirement of input lat/lon arrays having a size of 4. This was done to
> show that the results are the same between gc_qarea and area_poly_sphere
> (when input lat/lon arrays are of size 4). Try just calling
> area_poly_sphere and all should be well.
>
> On Mon, Feb 5, 2018 at 9:32 AM, Kunal Bali <kunal.bali9 at gmail.com> wrote:
>
>> Dear Dennis Sir,
>> Thanks for this suggestion.
>>
>> I tried that one, but I think these examples are applicable to
>> rectangular box only with the 4 lat lon grid points.
>>
>> I followed the examples on that page. e.g.
>>
>> ncl 0> rsph = 1.0
>> ncl 1> lonv = (/77.98,77.96,79.01,80.02,80.9
>> 8,81.57,81.98,83.01,84.00,83.99,83.01,83.01,80.98,81.00,80.0
>> 1,79.64,79.63,79.01,77.98/)
>> ncl 2>  latv = (/31.00,29.70,29.15,28.82,28.4
>> 3,28.01,27.98,27.47,27.38,28.64,28.99,29.40,29.56,29.99,30.0
>> 5,30.01,30.61,30.64,31.00/)
>> ncl 3> qorder     = gc_clkwise(latv, lonv)
>> ncl 4> qarea_gc   = gc_qarea(latv, lonv)
>> fatal:gc_qarea: the last (rightmost) dimension of arrays must be 4
>> fatal:["Execute.c":8576]:Execute: Error occurred at or near line 4
>>
>>
>>
>>
>> ---
>> Kunal Bali
>>
>>
>>
>>
>>
>> On Mon, Feb 5, 2018 at 9:09 PM, Dennis Shea <shea at ucar.edu> wrote:
>>
>>> Did you look at any of the functions?
>>>
>>> Click "Functions" ; Click "Alphabetical Listing"; Search 'area'
>>>
>>> Keep going till you find something: Like .......
>>>
>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/area_pol
>>> y_sphere.shtml
>>>
>>> On Mon, Feb 5, 2018 at 5:32 AM, Kunal Bali <kunal.bali9 at gmail.com>
>>> wrote:
>>>
>>>> Dear NCL users,
>>>>
>>>> I have coordinates such as
>>>> lonv = (/77.98,77.96,79.01,80.02,80.98,81.57,81.98,83.01,84.00,83.9
>>>> 9,83.01,83.01,80.98,81.00,80.01,79.64,79.63,79.01,77.98/)
>>>>
>>>>   latv = (/31.00,29.70,29.15,28.82,28.43,28.01,27.98,27.47,27.38,28.6
>>>> 4,28.99,29.40,29.56,29.99,30.05,30.01,30.61,30.64,31.00/)
>>>>
>>>>
>>>> from that, I am able to plot the polygon line e.g.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> So, could anyone please let me know how to calculate the area (in km)
>>>> of this polygon box?
>>>>
>>>>
>>>> thank you
>>>> ---
>>>> Kunal Bali
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>
>>
>
>
> --
> 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/20180205/6a8dcd94/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: area.png
Type: image/png
Size: 27216 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180205/6a8dcd94/attachment-0001.png>
```