[R-sig-Geo] Rgdal and unsigned integers
Robert J. Hijmans
r.hijmans at gmail.com
Thu Aug 20 18:48:01 CEST 2009
Jonathan,
Do you only get negative values with files that should have values >
32767 ? If so, that would suggest that the .GIS files are always
interpreted as signed. I believe that values in .GIS are by definition
unsigned (as is common with remote sensing formats), and that there is
no flag for this in the header. I won't speculate where this goes
wrong, but it would be helpful to compare with pure gdal, e.g.
FWTools. Can you make the file available?
For now, I believe you can correct for this :
stnd <- raster("stand_bm.gis", values = T)
stnd[stnd < 0] <- stnd[stnd < 0] + 66535
(only use this for files with 2 byte pixels!)
Robert
On Thu, Aug 20, 2009 at 6:58 AM, Jonathan
Thompson<jthomps 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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
More information about the R-sig-Geo
mailing list