# Methods

## Generic methods

nes.methods.cell_measures.calculate_cell_area(grid_corner_lon, grid_corner_lat, earth_radius_minor_axis=6356752.3142, earth_radius_major_axis=6378137.0)

  Calculate the area of each cell of a grid.

  ### Parameters

  grid_corner_lonarray

    An Array with longitude bounds of grid.

  grid_corner_latarray

    An Array with longitude bounds of grid.

  earth_radius_minor_axisfloat

    Radius of the minor axis of the Earth.

  earth_radius_major_axisfloat

    Radius of the major axis of the Earth.

nes.methods.cell_measures.calculate_geometry_area(geometry_list, earth_radius_minor_axis=6356752.3142, earth_radius_major_axis=6378137.0)

  Get coordinate bounds and call function to calculate the area of each cell of a set of geometries.

  ### Parameters

  geometry_listList

    A List with polygon geometries.

  earth_radius_minor_axisfloat

    Radius of the minor axis of the Earth.

  earth_radius_major_axisfloat

    Radius of the major axis of the Earth.

nes.methods.cell_measures.calculate_grid_area(self)

  Get coordinate bounds and call function to calculate the area of each cell of a grid.

  ### Parameters

  selfnes.Nes

    Source projection Nes Object.

## Horizontal interpolation

nes.methods.horizontal_interpolation.interpolate_horizontal(self, dst_grid, weight_matrix_path=None, kind='NearestNeighbour', n_neighbours=4, info=False, to_providentia=False, only_create_wm=False, wm=None, flux=False)

  Horizontal methods from one grid to another one.

  ### Parameters

  selfnes.Nes

    Source projection Nes Object.

  dst_gridnes.Nes

    Final projection Nes object.

  weight_matrix_pathstr, None

    Path to the weight matrix to read/create.

  kindstr

    Kind of horizontal interpolation. Accepted values: [“NearestNeighbour”, “Conservative”].

  n_neighboursint

    Used if kind == NearestNeighbour. Number of nearest neighbours to interpolate. Default: 4.

  infobool

    Indicates if you want to print extra info during the methods process.

  to_providentiabool

    Indicates if we want the interpolated grid in Providentia format.

  only_create_wmbool

    Indicates if you want to only create the Weight Matrix.

  wmNes

    Weight matrix Nes File.

  fluxbool

    Indicates if you want to calculate the weight matrix for flux variables.

## Spatial join

nes.methods.spatial_join.spatial_join(self, ext_shp, method=None, var_list=None, info=False, apply_bbox=True)

  Compute overlay intersection of two GeoPandasDataFrames.

  ### Parameters

  selfnes.Nes

    A Nes Object.

  ext_shpGeoPandasDataFrame or str

    File or path from where the data will be obtained on the intersection.

  methodstr

    Overlay method. Accepted values: [“nearest”, “intersection”, “centroid”].

  var_listList or None or str

    Variables that will be included in the resulting shapefile.

  infobool

    Indicates if you want to print the process info.

  apply_bboxbool

    Indicates if you want to reduce the shapefile to a bbox.

## Vertical interpolation

nes.methods.vertical_interpolation.add_4d_vertical_info(self, info_to_add)

  To add the vertical information from other source.

  ### Parameters

  selfnes.Nes

    Source Nes object.

  info_to_addnes.Nes, str

    Nes object with the vertical information as variable or str with the path to the NetCDF file that contains the vertical data.

nes.methods.vertical_interpolation.interpolate_vertical(self, new_levels, new_src_vertical=None, kind='linear', extrapolate_options=False, info=None, overwrite=False)

  Vertical interpolation.

  ### Parameters

  selfNes

    Source Nes object.

  new_levelsList

    A List of new vertical levels.

  new_src_verticalnes.Nes, str

    Nes object with the vertical information as variable or str with the path to the NetCDF file that contains the vertical data.

  kindstr

    Vertical methods type.

  extrapolate_optionsbool or tuple or None or number or NaN
    If bool:

      - If True, both extrapolation options are set to “extrapolate”.

      - If False, extrapolation options are set to (“bottom”, “top”).

    If tuple:

      - The first element represents the extrapolation option for the lower bound.

      - The second element represents the extrapolation option for the upper bound.

      - If any element is bool:

          - If True, it represents “extrapolate”.

          - If False:

              - If it”s the first element, it represents “bottom”.

              - If it”s the second element, it represents “top”.

      - If any element is None, it is replaced with numpy.nan.

      - Other numeric values are kept as they are.

      - If any element is NaN, it is kept as NaN.

    If None:

      - Both extrapolation options are set to (NaN, NaN).

    If number:

      - Both extrapolation options are set to the provided number.

    If NaN:

      - Both extrapolation options are set to NaN.

  info: None, bool

    Indicates if you want to print extra information.

  overwrite: bool

    Indicates if you want to compute the vertical interpolation in the same object or not.