calculate_mean_value_in_neighbouring_cells
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
calculate_mean_value_in_neighbouring_cells [2019/02/25 18:05] – stritiha | calculate_mean_value_in_neighbouring_cells [2023/04/21 16:04] (current) – irladmin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Mean of neighboring | + | ==== Mean of neighbouring |
This script calculates the mean of a continuous variable (e.g. % forest cover) in a specified window around each cell. It runs before the first iteration (i.e. to prepare the input data). | This script calculates the mean of a continuous variable (e.g. % forest cover) in a specified window around each cell. It runs before the first iteration (i.e. to prepare the input data). | ||
Line 42: | Line 42: | ||
# number of pixels to take into account for the neighborhood | # number of pixels to take into account for the neighborhood | ||
npix = int(d/ | npix = int(d/ | ||
- | print SCRIPT_NAME, | + | print(SCRIPT_NAME, |
input_data = getNodeByName(nodes_data, | input_data = getNodeByName(nodes_data, | ||
if (not input_data): | if (not input_data): | ||
- | print SCRIPT_NAME, | + | print(SCRIPT_NAME, |
return [] | return [] | ||
# create a list with only the prob of the state of interest (road) | # create a list with only the prob of the state of interest (road) | ||
Line 59: | Line 59: | ||
| | ||
# check if the values are correct | # check if the values are correct | ||
- | print " | + | print(" |
| | ||
# create 2D array from the vector (easier for edge problems) | # create 2D array from the vector (easier for edge problems) | ||
Line 86: | Line 86: | ||
neighb[i,j] = average | neighb[i,j] = average | ||
# check maximum and minimum | # check maximum and minimum | ||
- | print " | + | print(" |
- | print " | + | print(" |
# write the values into the node_data format | # write the values into the node_data format | ||
# into a continuous node format | # into a continuous node format | ||
Line 93: | Line 93: | ||
# translate to 1D list | # translate to 1D list | ||
neighb_list = neighb.flatten().tolist() | neighb_list = neighb.flatten().tolist() | ||
- | print " | + | print(" |
| | ||
new_nodes_data = [{' | new_nodes_data = [{' | ||
| | ||
for i in range(CELLS_PRINTING): | for i in range(CELLS_PRINTING): | ||
- | print " | + | print(" |
return new_nodes_data | return new_nodes_data | ||
calculate_mean_value_in_neighbouring_cells.1551114339.txt.gz · Last modified: 2023/04/21 15:30 (external edit)