[R-sig-Geo] Rgdal and unsigned integers

Jonathan Thompson jthomps at fas.harvard.edu
Thu Aug 20 22:57:21 CEST 2009


Thank you Barry and Robert

This is all very interesting.   When I use the FWTools Shell and the 
gdalinfo command it says that the Min value is zero (see below) and max 
is 48499. This is different than the summary in Rgdal, which produced 
the negative values.   So I guess the problem is in the Rgdal.

Also, when I try Robert's proposed fix:

stnd <- raster("stand_bm.gis", values = T)
stnd[stnd < 0] <- stnd[stnd < 0] + 66535

It creates an entirely new map (i.e. one with brand new values at the 
high end of the range)

So, I'm still awfully confused.   Any further help would be deeply 
appreciated.

Thanks Jonathan

C:\Program Files\FWTools2.4.2>gdalinfo stand_bm.gis
Driver: LAN/Erdas .LAN/.GIS
Files: c:\landis\harvest_problem\FTT-N_MinT-N\stand_bm.gis
       c:\landis\harvest_problem\FTT-N_MinT-N\stand_bm.gsw
Size is 1758, 839
Coordinate System is:
LOCAL_CS["Unknown",
    UNIT["Meter",1]]
Origin = (33773.261718750000000,945478.062500000000000)
Pixel Size = (100.000000000000000,-100.000000000000000)
Corner Coordinates:
Upper Left  (   33773.262,  945478.063)
Lower Left  (   33773.262,  861578.063)
Upper Right (  209573.262,  945478.063)
Lower Right (  209573.262,  861578.063)
Center      (  121673.262,  903528.063)
Band 1 Block=1758x1 Type=Int16, ColorInterp=Undefined
  Min=0.000 Max=48499.000
  Minimum=0.000, Maximum=48499.000, Mean=12833.830, StdDev=13635.800
  Metadata:
    STATISTICS_MINIMUM=0
    STATISTICS_MAXIMUM=48499
    STATISTICS_MEAN=12833.830260712
    STATISTICS_MEDIAN=8.7254821994872e-239
    STATISTICS_MODE=3.9864100424366e-293
    STATISTICS_STDDEV=13635.800289332
    LAYER_TYPE=thematic


----

On Thu, Aug 20, 2009 at 6:58 AM, Jonathan
Thompson<jtho... at fas.harvard.edu> wrote:
> Dear List,
>
> I use a forest landscape model, which produces 16 bit unsigned ".gis" raster
> files. I often read and manipulate them using rgdal and the raster package
> in R.
>
> However, sometimes, when I read in a unsigned 16 bit .gis, I get the
> following:
>
> stnd <- raster("stand_bm.gis", values = T)
>
> summary(stnd)
> Cells:  1474962
> NAs  :  0
>
> Values             Min.    -32140
> 1st Qu.      0
> Median       0
> Mean      8316
> 3rd Qu.  19180
> Max.     29620
>
>
> Where are these negative values coming from?   Opening the same file in
> ArcGIS confirms what I know to be true:
>
> Pixel Type  = unsigned integer
> Pixel Depth = 16 bit
> Min = 0
> Max = 48499
>
> Is there anyway to force raster (or RGDAL) to treat it like an unsigned
> integer?
>
> Thank you,
> Jonathan Thompson
> Harvard Forest
> Harvard University
> Petersham, MA 01366



More information about the R-sig-Geo mailing list