[ncl-talk] area of a shapefile

Vanúcia Schumacher vanucia-schumacher at hotmail.com
Mon Mar 12 08:14:40 MDT 2018


      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 ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180312/d297bed2/attachment.html>


More information about the ncl-talk mailing list