[R] writeRaster dataType changes

White, Emma emma.white at sdstate.edu
Thu Sep 25 20:08:12 CEST 2014


Hi,

I am reading in some raster files and converting them to GeoTiff (using 
the raster package), I want them to be 8 bit unsigned integer (values in 
the case of this particular raster range from 0 to 55). However when 
writing the raster to GeoTiff R seems to assign it to dataType "FLT4S" 
despite specifying the dataType. See example code below:

foo<- raster(raster.files[1],datatype = INT1U)
dataType(foo)
[1] "INT1U"
fool<- 
writeRaster(foo,filename=paste("../test/",raster.files[1],sep=""), 
format="GTiff",dataType = 'INT1U',overwrite=TRUE)
dataType(fool)
[1] "FLT4S"

Any help/ insight would be appreciated. Thanks!


Emma

-- 
Emma White
PhD Candidate
Geospatial Science Center of Excellence
South Dakota State University
Email: Emma.White at sdstate.edu
Web: http://globalmonitoring.sdstate.edu/people.php?view=3&a=show&id=86



More information about the R-help mailing list