writeRaster dataType changes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

writeRaster dataType changes

Emma-2
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: [hidden email]
Web: http://globalmonitoring.sdstate.edu/people.php?view=3&a=show&id=86

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: writeRaster dataType changes

Pascal Oettli-2
Hi Emma,

In writeRaster(), the argument is "datatype", not "dataType".

Hope this helps,
Pascal


On Fri, Sep 26, 2014 at 3:08 AM, White, Emma <[hidden email]> wrote:

> 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: [hidden email]
> Web: http://globalmonitoring.sdstate.edu/people.php?view=3&a=show&id=86
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



--
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.