[GRASS-dev] [GRASS GIS] #3415: Mark raster NULL values as None in PyGRASS
GRASS GIS
trac at osgeo.org
Thu Sep 7 21:56:56 PDT 2017
#3415: Mark raster NULL values as None in PyGRASS
--------------------------+-------------------------
Reporter: marisn | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.4.0
Component: PyGRASS | Version: unspecified
Resolution: | Keywords:
CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Comment (by zarch):
Replying to [ticket:3415 marisn]:
> At the moment PyGRASS is providing raster NULL values as is (i.e. for
CELL type they are marked as -2147483648). There is no function to check
if value is NULL (in C it is done with Rast_is_c/f/d_null_value).
>
> The best would be to replace raster NULL values with None when raster is
read and None with NULL representation when it is written back. Such
approach would greatly simplify use of rasters in PyGRASS (i.e. "if
myrast[row][col] is not None:")
Well, but then for CELL raster instead to have an array of integer you
will have an array of objects, I did not perform any benchmark but it
seems not very intuitive as well.
Perhaps we can define a `CELL_NULL` variable, and then you can write code
as: `if myrast[row] != CELL_NULL:` or an equivalent function instead of
`numpy.isnan` get `pygrass.raster.isnull`.
What do you think?
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3415#comment:1>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list