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 * other version 2 cell representations * version 1 cell representations these can be returned by BUT NOT passed to a csf2 function * this one CANNOT be returned by NOR passed to a csf2 function
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 * version 2 datatypes these two can be returned by or passed to a csf2 function * this one CANNOT be returned by NOR passed to a csf2 function

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);
}