id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,cpu,platform 166,short integer overflow with r.in.gdal,dylan,grass-dev@…,"Noticed that importing Arc ASCII grid files with r.in.gdal can lead to data corruption when the input file contains integer values larger than what can be stored in a short integer (>32767). See the test case and attached file below. test case: {{{ # setup in spearfish60 location g.region res=1000 -pa # make a map with values larger than what a short integer can hold r.mapcalc ""large_int_map = rand(10000, 78000)"" # check raster info: r.info large_int_map -r min=10000 max=77594 # export to Arc ASCII format r.out.arc in=large_int_map out=big_int_arc_file.asc # import with GDAL: r.in.gdal -o in=big_int_arc_file.asc out=big_int_arc_file # we are stuck with short integer values and data corruption: r.info big_int_arc_file -r min=-31293 max=32420 }}} It looks like the culprit may be associated with the following lines from the r.out.gdal source (main.c:677 | revision 31323): {{{ /* -------------------------------------------------------------------- */ /* Select a cell type for the new cell. */ /* -------------------------------------------------------------------- */ eRawGDT = GDALGetRasterDataType( hBand ); 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; } }}} ",task,closed,major,6.4.0,Default,svn-trunk,fixed,gdal,,Unspecified,Unspecified