Skip to content

readGDAL re-mapping data to 0-255

5 messages · Michael Sumner, Biuw, Martin, Roger Bivand

#
On Wed, 6 Mar 2013, Biuw, Martin wrote:

            
This appears to indicate that the files do not only differ in NoDataValue, 
but also in storage form. Does examining the output of GDALinfo() on both 
tell you anything? Is one a signed 16-bit integer, the other Byte? Maybe 
paste some of the output into a follow-up?

Roger

  
    
#
Ah, that was the problem.
The file with -9999 that works fine is Int16:

       apparent band summary:
         GDType Bmin Bmax     Bmean      Bsd hasNoDataValue NoDataValue
       1  Int16  -26    0 -3.130923 3.832138           TRUE       -9999

While the other one is Byte:
    
      apparent band summary:
         GDType Bmin Bmax     Bmean      Bsd hasNoDataValue NoDataValue
       1   Byte  -26    0 -3.089263 3.864005           TRUE        -128

So this sort of problem basically stems from the way ArcGIS saves the geoTiff depending on the data range? Or is there a way to specify to readGDAL how to deal with Byte or Int16 data?
Thanks for the help!
Martin

-----Original Message-----
From: Roger Bivand [mailto:Roger.Bivand at nhh.no] 
Sent: 06 March 2013 12:47
To: Biuw, Martin
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] readGDAL re-mapping data to 0-255
On Wed, 6 Mar 2013, Biuw, Martin wrote:

            
This appears to indicate that the files do not only differ in NoDataValue, but also in storage form. Does examining the output of GDALinfo() on both tell you anything? Is one a signed 16-bit integer, the other Byte? Maybe paste some of the output into a follow-up?

Roger
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
#
On Wed, 6 Mar 2013, Biuw, Martin wrote:

            
If the input data are Byte, you may try the rgdal toSigned() function:

x <- c(1:10, 127:129, 240:256)
toSigned(x, 8)

which probably will not respect the -128, but you can then untangle that 
later with is.na(). You'll need to check the output as the function is not 
used often and may not do what you need. The function was added to the 
package in September 2009:

https://stat.ethz.ch/pipermail/r-sig-geo/2009-September/006387.html

Hope this helps,

Roger