[GRASS-dev] r.reclass only for int maps

Hi,

is there any reason why r.reclass does not support FP raster maps?

Thanks, Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

On Sat, Oct 8, 2011 at 10:12 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

is there any reason why r.reclass does not support FP raster maps?

I found this message in my inbox:

On Fri, May 16, 2008 at 2:58 AM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Michael Barton wrote:

Related to this, does r.reclass only produce integer maps?

Yes; a reclass table maps integers to integers.

There are "FP reclass" functions in libgis, but these are only used by
r.recode. There are no functions to read/write a "struct FPReclass"
from/to a file, and no way to create an FP equivalent of a reclass
map.

I suppose that the situation did not change.

Markus

Martin Landa wrote:

is there any reason why r.reclass does not support FP raster maps?

The immediate reason is that the underlying functionality in libgis
doesn't support it. r.reclass merely creates the tables; it's libgis
which uses them.

It would be a relatively simple matter to extend the existing
functionality to allow reclassing an integer map to an FP map (i.e.
the reclass table could contain FP values instead of integers).

It would be somewhat more complex to support "reclassing" an FP map. I
use quotes because the term implies that the data consists of discrete
classes (categories). Ultimately, a reclass table is just that: a
table, i.e. an array, and you can't use floats as array indices.

While there's no fundamental issue with defining a mapping whose
domain is floating-point numbers (we already do this for colour
tables), it is bound to be significantly slower than the integer case.

And probably less useful.

A mapping from integers to integers can be described by a look-up
table, but a mapping from floats to either integers or floats can't be
(at least, not realistically). So you have to decide upon the nature
of the approximation: piecewise linear, cubic spline, rational spline,
or something else entirely? Or do we merge r.mapcalc into libraster so
that maps can be "reclassed" by arbitrary algebraic expressions?

--
Glynn Clements <glynn@gclements.plus.com>

2011/10/8 Markus Neteler <neteler@osgeo.org>:

Yes; a reclass table maps integers to integers.

then probably r.reclass should at least print a warning when `input`
is CELL raster map(?).

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

Martin Landa wrote:

>> Yes; a reclass table maps integers to integers.

then probably r.reclass should at least print a warning when `input`
is CELL raster map(?).

Presumably you mean "... is *not* a CELL ..."?

Currently, it actually checks the map type so that it can use the
correct format for printing the range. It should generate a fatal
error if the input= map type isn't CELL.

--
Glynn Clements <glynn@gclements.plus.com>