[GRASSLIST:2848] Re: import raster

Markus Neteler neteler at itc.it
Fri Mar 5 05:07:23 EST 2004


On Thu, Mar 04, 2004 at 04:55:44PM +0100, Daniele Scarselli wrote:
> Hi,
> I've a problem importing some raster:
> I use r.in.gdal to import a raster and the results are files over 100 mb for 
> every raster.
> With r.compress I reduce to 17,4 mb.
> Is there a method to reduce again these files?
> I think that GRASS take the raster as a 8 bit image while the original is 
> black and white (1 bit)
> thanks
> Daniele Scarselli

The code portion in question will be (main.c from r.in.gdal):

   switch(eRawGDT) {
      case GDT_Float32:
      case GDT_Float64:
        data_type = FCELL_TYPE;
        eGDT = GDT_Float32;
        complex = FALSE;
        break;

      case GDT_Byte:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(0);
        raster_open_new_func = G_open_raster_new_uncompressed;
        break;

      case GDT_Int16:
      case GDT_UInt16:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(1);
        raster_open_new_func = G_open_raster_new_uncompressed;
        break;

      default:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(3);
        break;
    }

Anything to improve there?
The code portion in question will be (main.c from r.in.gdal):

   switch(eRawGDT) {
      case GDT_Float32:
      case GDT_Float64:
        data_type = FCELL_TYPE;
        eGDT = GDT_Float32;
        complex = FALSE;
        break;

      case GDT_Byte:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(0);
        raster_open_new_func = G_open_raster_new_uncompressed;
        break;

      case GDT_Int16:
      case GDT_UInt16:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(1);
        raster_open_new_func = G_open_raster_new_uncompressed;
        break;

      default:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(3);
        break;
    }

Anything to improve ther
The code portion in question will be (main.c from r.in.gdal):

   switch(eRawGDT) {
      case GDT_Float32:
      case GDT_Float64:
        data_type = FCELL_TYPE;
        eGDT = GDT_Float32;
        complex = FALSE;
        break;

      case GDT_Byte:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(0);
        raster_open_new_func = G_open_raster_new_uncompressed;
        break;

      case GDT_Int16:
      case GDT_UInt16:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(1);
        raster_open_new_func = G_open_raster_new_uncompressed;
        break;

      default:
        data_type = CELL_TYPE;
        eGDT = GDT_Int32;
        complex = FALSE;
        G_set_cell_format(3);
        break;
    }

GDAL provides:

./gcore/gdal.h

/*! Pixel data types */
typedef enum {
    GDT_Unknown = 0,
    /*! Eight bit unsigned integer */           GDT_Byte = 1,
    /*! Sixteen bit unsigned integer */         GDT_UInt16 = 2,
    /*! Sixteen bit signed integer */           GDT_Int16 = 3,
    /*! Thirty two bit unsigned integer */      GDT_UInt32 = 4,
    /*! Thirty two bit signed integer */        GDT_Int32 = 5,
    /*! Thirty two bit floating point */        GDT_Float32 = 6,
    /*! Sixty four bit floating point */        GDT_Float64 = 7,
    /*! Complex Int16 */                        GDT_CInt16 = 8,
    /*! Complex Int32 */                        GDT_CInt32 = 9,
    /*! Complex Float32 */                      GDT_CFloat32 = 10,
    /*! Complex Float64 */                      GDT_CFloat64 = 11,
    GDT_TypeCount = 12          /* maximum type # + 1 */
} GDALDataType;

Anything to improve in r.in.gdal (we all like small files)?

Markus




More information about the grass-user mailing list