## tools.InterpolationTool


The Interpolation and Assignment tool from MIKE+.


Usage

``` python
tools.InterpolationTool(database)
```


## Examples

Interpolate node diameter from connected links for the nodes which have NULL diameter.

``` python
>>> from mikeplus import Database
>>> db = Database("path/to/model.sqlite")
>>> tool = InterpolationTool(db)
>>> tool.interpolate_from_nearest_feature("msm_Node", "Diameter", "msm_Link", "Diameter", True, False, None)
>>> db.close()
```


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize the InterpolationTool with the given Database. |
| [direct_assign_value()](#direct_assign_value) | Set the target attribute as the fixed value. |
| [interpolate_from_DEM()](#interpolate_from_DEM) | Interpolate target attribute from specified item number in raster layer. |
| [interpolate_from_nearest_feature()](#interpolate_from_nearest_feature) | Interpolate target attribute from nearest source in search radius. |
| [interpolate_from_neighobour()](#interpolate_from_neighobour) | Interpolate target attribute from the source attribute along the network. |
| [interpolation_IDW()](#interpolation_IDW) | Interpolate target attribute from the specified max number of sources in search radius. |

------------------------------------------------------------------------


#### \_\_init\_\_()


Initialize the InterpolationTool with the given Database.


Usage

``` python
__init__(database)
```


##### Parameters


`database: Database`  
A Database object for the MIKE+ model.


------------------------------------------------------------------------


#### direct_assign_value()


Set the target attribute as the fixed value.


Usage

``` python
direct_assign_value(
    target_Db_name,
    target_attribute,
    fixed_value,
    only_null_values=True,
    assign_val_as_missing=False,
    value_as_missing=None,
    muids=None
)
```


##### Parameters


`target_Db_name: string`  
target table name, the table you want to interpolate

`target_attribute: string`  
target attribute name, the field in the table, which you want to interpolate

`fixed_value: float`  
The fixed value is used to set the missing value.

`only_null_values: bool = ``True`  
If true, only interpolate null value or defined as missing value in target attribute in target table. Otherwise, interpolate all. By default True

`assign_val_as_missing: bool = ``False`  
If true, treat `value_as_missing` as a missing value. By default False

`value_as_missing: float = None`  
Specify the value as the missing value, by default None

`muids: iterable of str = None`  
MUIDs of the target table elements to assign values to. By default None, which means all elements. `only_null_values` still applies within the given elements. An empty iterable assigns nothing, and MUIDs not in the target table are ignored. A single string raises TypeError; wrap it in a list.


------------------------------------------------------------------------


#### interpolate_from_DEM()


Interpolate target attribute from specified item number in raster layer.


Usage

``` python
interpolate_from_DEM(
    target_Db_Name,
    target_attribute,
    raster_file,
    item_number,
    only_null_values=True,
    assign_val_as_missing=False,
    value_as_missing=None,
    muids=None
)
```


##### Parameters


`target_Db_Name: string`  
target table name, the table you want to interpolate

`target_attribute: string`  
target attribute name, the field in the table, which you want to interpolate

`raster_file: string`  
raster file path

`item_number: int`  
the item number in raster file used to interpolate

`only_null_values: bool = ``True`  
If true, only interpolate null value or defined as missing value in target attribute in target table. Otherwise, interpolate all. By default True

`assign_val_as_missing: bool = ``False`  
If true, treat `value_as_missing` as a missing value. By default False

`value_as_missing: float = None`  
Specify the value as the missing value, by default None

`muids: iterable of str = None`  
MUIDs of the target table elements to assign values to. By default None, which means all elements. `only_null_values` still applies within the given elements. An empty iterable assigns nothing, and MUIDs not in the target table are ignored. A single string raises TypeError; wrap it in a list.


------------------------------------------------------------------------


#### interpolate_from_nearest_feature()


Interpolate target attribute from nearest source in search radius.


Usage

``` python
interpolate_from_nearest_feature(
    target_Db_Name,
    target_attribute,
    source_layer_name,
    source_attribute,
    only_null_values=True,
    assign_val_as_missing=False,
    value_as_missing=None,
    search_radius=300.0,
    muids=None
)
```


##### Parameters


`target_Db_Name: string`  
target table name, the table you want to interpolate

`target_attribute: string`  
target attribute name, the field in the table, which you want to interpolate

`source_layer_name: string`  
source_layer_name can be database table name, or a shape file path, the source is used to interpolate the target

`source_attribute: string`  
source attribute name, field name of source layer

`only_null_values: bool = ``True`  
If true, only interpolate null value or defined as missing value in target attribute in target table. Otherwise, interpolate all. By default True

`assign_val_as_missing: bool = ``False`  
If true, treat `value_as_missing` as a missing value. By default False

`value_as_missing: float = None`  
Specify the value as the missing value, by default None

`search_radius: float = ``300.0`  
the search radius to find the source, by default 300

`muids: iterable of str = None`  
MUIDs of the target table elements to assign values to. By default None, which means all elements. `only_null_values` still applies within the given elements. An empty iterable assigns nothing, and MUIDs not in the target table are ignored. A single string raises TypeError; wrap it in a list.


------------------------------------------------------------------------


#### interpolate_from_neighobour()


Interpolate target attribute from the source attribute along the network.


Usage

``` python
interpolate_from_neighobour(
    target_Db_name,
    target_attribute,
    source_layer_name,
    source_attribute,
    only_null_values=True,
    assign_val_as_missing=False,
    value_as_missing=None,
    assign_option=0,
    alongPath=False,
    max_neighbours=3,
    muids=None
)
```


##### Parameters


`target_Db_name: string`  
target table name, the table you want to interpolate

`target_attribute: string`  
target attribute name, the field in the table, which you want to interpolate

`source_layer_name: string`  
source table name, the table used to interpolate

`source_attribute: string`  
source attribute name, the field in source table used to interpolate

`only_null_values: bool = ``True`  
If true, only interpolate null value or defined as missing value in target attribute in target table. Otherwise, interpolate all. By default True

`assign_val_as_missing: bool = ``False`  
If true, treat `value_as_missing` as a missing value. By default False

`value_as_missing: float = None`  
Specify the value as the missing value, by default None

`assign_option: int = ``0`  
assign option, by default 0 AssignOption { ClosestNode=0, UpstreamElement=1, DownstreamElement=2, UpstreamMaxValue=3, UpstreamMinValue=4, DownlstreamMaxValue=5, DownstreamMinValue=6, MaxValueNeighbours=7, MinValueNeighbours=8 }

`alongPath: bool = ``False`  
If true, interpolate from neighbour. Otherwise, interpolate from network. By default False

`max_neighbours: int = ``3`  
the max neighbours with missing value along the network, by default 3

`muids: iterable of str = None`  
MUIDs of the target table elements to assign values to. By default None, which means all elements. `only_null_values` still applies within the given elements. An empty iterable assigns nothing, and MUIDs not in the target table are ignored. A single string raises TypeError; wrap it in a list.


------------------------------------------------------------------------


#### interpolation_IDW()


Interpolate target attribute from the specified max number of sources in search radius.


Usage

``` python
interpolation_IDW(
    target_Db_name,
    target_attribute,
    source_layer_name,
    source_attribute,
    only_null_values=True,
    assign_val_as_missing=False,
    value_as_missing=None,
    max_IDW_points=12,
    search_radius=300.0,
    muids=None
)
```


##### Parameters


`target_Db_name: string`  
target table name, the table you want to interpolate

`target_attribute: string`  
target attribute name, the field in the table, which you want to interpolate

`source_layer_name: string`  
source_layer_name can be database table name, or a shape file path, the source is used to interpolate the target

`source_attribute: string`  
source attribute name, field name of source layer

`only_null_values: bool = ``True`  
If true, only interpolate null value or defined as missing value in target attribute in target table. Otherwise, interpolate all. By default True

`assign_val_as_missing: bool = ``False`  
If true, treat `value_as_missing` as a missing value. By default False

`value_as_missing: float = None`  
Specify the value as the missing value, by default None

`max_IDW_points: int = ``12`  
the max source number used to interpolate, by default 12

`search_radius: float = ``300.0`  
the search radius to find the source, by default 300.0

`muids: iterable of str = None`  
MUIDs of the target table elements to assign values to. By default None, which means all elements. `only_null_values` still applies within the given elements. An empty iterable assigns nothing, and MUIDs not in the target table are ignored. A single string raises TypeError; wrap it in a list.
