open_simplex_noise#
Signature#
- open_simplex_noise(x_coordinates, y_coordinates, seed) Field#
Return a noise field based on the OpenSimplex noise function
- Parameters:
x_coordinates (Field) – X-coordinates (array / floating point)
y_coordinates (Field) – Y-coordinates (array / floating point)
seed (int) – Seed
- Returns:
New field with values in the range [-1, 1] (array / floating point)
Description#
Operation for creating noise fields that can be used, for example, to generate synthetic elevation models.
The cell_index operation can be used to create the argument to pass into the operation.
No-data handling#
A cell containing a no-data value in one of the input arrays results in a no-data value in the corresponding cell in the output array. No new no-data values are generated.
Example#
LUE_Rank const rank = 2;
LUE_Count const array_shape[] = {600, 400};
LUE_Field* condition_field = NULL;
{
LUE_BooleanElement const value = 1;
LUE_Literal* literal = lue_create_literal(value);
LUE_Scalar* scalar = lue_create_scalar(literal);
LUE_Array* condition_array = lue_create_array(rank, array_shape, scalar);
condition_field = lue_as_field(condition_array);
lue_destruct(scalar);
lue_destruct(literal);
}
LUE_Field* x_coordinates = NULL;
{
LUE_Field* const col_indices = lue_cell_index(condition_field, 1);
x_coordinates = lue_cast(col_indices, LUE_ElementType_Float32);
lue_destruct(col_indices);
}
LUE_Field* y_coordinates = NULL;
{
LUE_Field* const row_indices = lue_cell_index(condition_field, 0);
y_coordinates = lue_cast(row_indices, LUE_ElementType_Float32);
lue_destruct(row_indices);
}
int const seed = 5;
LUE_Field* result = lue_open_simplex_noise(x_coordinates, y_coordinates, seed);
lue_destruct(x_coordinates);
lue_destruct(y_coordinates);
lue_to_gdal(result, result_array_pathname, NULL);
lue_destruct(result);
Field const condition_array = as_field(create_array({600, 400}, BooleanElement{1}));
Field const x_coordinates = cast(cell_index(condition_array, 1), ElementType::Float32);
Field const y_coordinates = cast(cell_index(condition_array, 0), ElementType::Float32);
int const seed = 5;
Field const result = open_simplex_noise(x_coordinates, y_coordinates, seed);
to_gdal(result, result_array_pathname);
boolean_type = lfrx.boolean_element_type
floating_point_type = lfrx.floating_point_element_types[0]
condition = lfrx.as_field(
lfrx.create_array((600, 400), lfrx.create_scalar(1, boolean_type))
)
x_coordinates = lfrx.cast(lfrx.cell_index(condition, 1), floating_point_type)
y_coordinates = lfrx.cast(lfrx.cell_index(condition, 0), floating_point_type)
result = lfrx.open_simplex_noise(x_coordinates, y_coordinates, seed=5)
lfrx.to_gdal(result, str(result_array_path))
|
|---|