[ncl-talk] area of a shapefile

Dennis Shea shea at ucar.edu
Mon Mar 12 08:25:03 MDT 2018


You could click "Functions" [Alphabetical]; then, search for the word 'area'
Keep clicking ....

https://www.ncl.ucar.edu/Document/Functions/Built-in/area_poly_sphere.shtml

Also,
https://www.ncl.ucar.edu/Document/Functions/Built-in/gc_qarea.shtml
See Examples

Good luck


On Mon, Mar 12, 2018 at 8:14 AM, Vanúcia Schumacher <
vanucia-schumacher at hotmail.com> wrote:

>       Hi NCL users,
>
> I would like help to calculate the area from the shapefile.
> Any ideas how can I proceed?
>
>
>           hdr = readAsciiHead("inventory.asc", 7)
>        ncols = stringtoint( str_get_field(hdr(0), 2, " ") )
>       nrows = stringtoint( str_get_field(hdr(1), 2, " ") )
>        lonLL = stringtofloat( str_get_field(hdr(2), 2, " ") )
>         latLL = stringtofloat( str_get_field(hdr(3), 2, " ") )
>   deltaLon = stringtofloat( str_get_field(hdr(4), 2, " " ) )
>   deltaLat = stringtofloat( str_get_field(hdr(5), 2, " ") )
> missingVal = stringtofloat( str_get_field(hdr(6), 2, " ") )
>
> data           = readAsciiTable("inventory.asc",ncols,"float",7)
>                      data at _FillValue =-9999.0
>
> ;----- construct 1D coordinates....
> lons             = ispan(0,ncols-1,1) * deltaLon + lonLL
> lats             = ispan(0,nrows-1,1) * deltaLat + latLL
> lats             = lats(::-1)
>
> ;---- gsn_coordinates wants 2D coordinate arrays
> data at lon2d       = conform_dims((/ nrows, ncols/), lons, 1)
> data at lat2d       = conform_dims((/ nrows, ncols/), lats, 0)
> data at _FillValue  = missingVal
>
> ;---- Open shapefile and read lat/lon values.
>
> shp_filename    =  "Cuenca_Universidad.shp"
> data_mask       = shapefile_mask_data(data,shp_filename,True)
>
> ;--- Area ?
>
>
> _______________________________________________
> 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/20180312/5b5a7a9e/attachment.html>


More information about the ncl-talk mailing list