Skip to content

Commit

Permalink
Warn about the nulls by default. Warn when integers are used (differe…
Browse files Browse the repository at this point in the history
…nt null check is needed).
  • Loading branch information
wenzeslaus committed Jul 10, 2023
1 parent f86aa4b commit 7b92a6d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/vector/v.rast.move/v.rast.move.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
# % key: nulls
# % type: string
# % options: zeros,warning,error
# % answer: warning
# % label: Handling of null values
# % description: Null (no-data) values in rasters will be considered zeros, cause a warning or an error
# % description: zeros;Null value will be converted to zeros;warning;A null value will cause a warning (one for each raster) and will be converted to zero;error;A null value will cause an error
Expand Down Expand Up @@ -131,23 +132,23 @@ def move_vector(
Vect_cat_set(new_line.c_cats, 1, first_cat.value)
output_vector.write(new_line)

detail = _("(set nulls to 'zeros' to silence this warning)")
if x_null:
gs.warning(
_("Null value encountered in {raster} (X): {n}x").format(
raster=x_raster_name, n=x_null
_("Null value encountered in {raster} (X): {n}x {detail}").format(
raster=x_raster_name, n=x_null, detail=detail
)
)
if y_null:
gs.warning(
_("Null value encountered in {raster} (Y): {n}x").format(
raster=y_raster_name, n=y_null
_("Null value encountered in {raster} (Y): {n}x {detail}").format(
raster=y_raster_name, n=y_null, detail=detail
)
)

x_raster.close()
y_raster.close()


def main():
options, unused_flags = gs.parser()

Expand All @@ -156,6 +157,17 @@ def main():
y_raster_name = options["y_raster"]
output_vector_name = options["output"]

for name in set([x_raster_name, y_raster_name]):
raster_type = gs.raster_info(name)["datatype"]
if raster_type == "CELL":
gs.warning(
_(
"Raster input {name} is CELL (integer), but null-value "
"handling is supported only for floating-point rasters "
"(FCELL and DCELL)"
).format(name=name)
)

try:
move_vector(
input_vector_name=input_vector_name,
Expand Down

0 comments on commit 7b92a6d

Please sign in to comment.