unifhy.BritishNationalGrid.cell_area
- BritishNationalGrid.cell_area
The horizontal area for the grid cells of the SpaceDomain in square metres given as a
cf.Fieldand returned as anumpy.ndarray.- Parameters
- areas:
cf.Field The field containing the horizontal grid cell area. The shape of the data array must be the same as the SpaceDomain. The field data must contain surface area values in square metres.
- areas:
- Returns
numpy.ndarrayThe array containing the horizontal grid cell area values in square metres. If not set previously, computed automatically.
Examples
Retrieving automatically computed grid cell area:
>>> grid = BritishNationalGrid.from_extent_and_resolution( ... projection_y_coordinate_extent=(12000, 15000), ... projection_y_coordinate_resolution=1000, ... projection_x_coordinate_extent=(80000, 84000), ... projection_x_coordinate_resolution=2000 ... ) >>> print(grid.cell_area) [[2000000. 2000000.] [2000000. 2000000.] [2000000. 2000000.]] >>> print(grid) BritishNationalGrid( shape {Y, X}: (3, 2) Y, projection_y_coordinate (3,): [12500.0, 13500.0, 14500.0] m X, projection_x_coordinate (2,): [81000.0, 83000.0] m Y_bounds (3, 2): [[12000.0, ..., 15000.0]] m X_bounds (2, 2): [[80000.0, ..., 84000.0]] m cell_area (3, 2): [[2000000.0, ..., 2000000.0]] m2 )
Manually assigning grid cell area values:
>>> import numpy >>> areas = grid.to_field() >>> areas.set_data(numpy.array([[1999999, 1999999], ... [1999999, 1999999], ... [1999999, 1999999]])) >>> areas.units = 'm2' >>> grid.cell_area = areas >>> print(grid.cell_area) [[1999999. 1999999.] [1999999. 1999999.] [1999999. 1999999.]]