NAME
Rdup - create a new map by cloning another one
SYNOPSIS
#include "csf.h"
MAP *Rdup
(
const char *toFile,
const MAP *from,
CSF_CR cellRepr,
CSF_VS dataType
);
PARAMETERS
-
const char *toFile
-
file name of map to be created
-
const MAP *from
-
map to clone from
-
CSF_CR cellRepr
-
cell representation of new map
Possible values for a
CSF_CR
are as follows:
* preferred version 2 cell representations
- CR_UINT1 - Boolean, ldd and small nominal and small ordinal.
- CR_INT4 - Large nominal and large ordinal.
- CR_REAL4 - Single scalar and single directional.
* other version 2 cell representations
- CR_REAL8 - Double scalar or directional, and also the only type that
can hold all
cell representation without loss of precision.
* version 1 cell representations
these can be returned by BUT NOT passed to a csf2 function
- CR_INT1 -
.
- CR_INT2 -
.
- CR_UINT2 -
.
- CR_UINT4 -
.
* this one CANNOT be returned by NOR passed to a csf2 function
- CR_UNDEFINED - Just some value different from the rest.
-
CSF_VS dataType
-
datatype/valuescale of new map
Possible values for a
CSF_VS
are as follows:
* version 1 datatypes,
these can be returned by BUT NOT passed to a csf2 function
- VS_NOTDETERMINED - Version 1.
- VS_CLASSIFIED - Version 1.
- VS_CONTINUOUS - Version 1.
* version 2 datatypes
these two can be returned by or passed to a csf2 function
- VS_BOOLEAN - Boolean, always UINT1, values: 0,1 or MV_UINT1.
- VS_NOMINAL - Nominal, UINT1 or INT4.
- VS_ORDINAL - Ordinal, UINT1 or INT4.
- VS_SCALAR - Scalar, REAL4 or (maybe) REAL8.
- VS_DIRECTION - Directional REAL4 or (maybe) REAL8, -1 means no direction.
- VS_LDD - Local drain direction, always UINT1, values: 1-9 or MV_UINT1.
* this one CANNOT be returned by NOR passed to a csf2 function
- VS_UNDEFINED - Just some value different from the rest.
DESCRIPTION
Rdup creates a new empty map from the specifications of another map.
No cell values are copied. It uses a call to Rcreate to create the
map. See Rcreate for legal values of the args cellRepr and valueScale.
RETURNS
the map handle of the newly created map or NULL in case of an
error
MERRNO
NOT_RASTER plus the Merrno codes of Rcreate
EXAMPLE
#include "csf.h"
/* make a boolean map
* with minimal checking
*/
void main(int argc, char *argv[] )
{
REAL8 inValue;
UINT1 outValue;
MAP *in, *out;
size_t r,c;
if (argc != 2)
{
fprintf(stderr,"%s: no file specified\n",argv[0]);
exit(1);
}
in = Mopen(argv[1], M_READ);
if (in == NULL)
{
Mperror(argv[1]);
exit(1);
}
RuseAs(in, CR_REAL8);
out = Rdup(argv[2], in, CR_UINT1, VS_BOOLEAN);
if (out == NULL)
{
Mperror(argv[2]);
exit(1);
}
for(r=0; r < RgetNrRows(in); r++)
for(c=0; c < RgetNrCols(in); c++)
{
RgetCell(in,r,c,&inValue);
if (IS_MV_REAL4(&inValue))
outValue = MV_UINT1;
else
outValue = inValue > 0;
RputCell(out,r,c,&outValue);
}
Mclose(in);
Mclose(out);
exit(0);
}