[R-sig-Geo] writeRaster: BSQ despite BIL is requested

Agustin Lobo @loboli@t@@ @ending from gm@il@com
Wed Dec 19 14:45:34 CET 2018


Thanks Roger,

Just to summarize, not only the hdr files are correct, the hdr files
are consistent with the ordering in the data files:

require(rgdal)
require(raster)
m <- matrix(rep(10,20),ncol=5)
b <- brick(raster(m),raster(10*m),raster(100*m))
b
writeRaster(b, file="bwrast", format="ENVI", datatype="INT2U",
            bandorder="BIL", overwrite=TRUE)

writes a correct BSQ file, despite having requested BIL order

writeRaster(b, file="bwrast2", format="ENVI", datatype="INT2U",
            options="INTERLEAVE=BIL", overwrite=TRUE)

writes a correct BIL file (and this is a useful solution, thanks).

I tend to think that the fact that writeRaster() ignores
bandorder="BIL" is a bug.

Agus
(mi R is using Loaded GDAL runtime: GDAL 2.3.2, released 2018/09/21)

On Wed, Dec 19, 2018 at 11:52 AM Roger Bivand <Roger.Bivand using nhh.no> wrote:
>
> On Wed, 19 Dec 2018, Agustin Lobo wrote:
>
> > I do
> >
> > writeRaster(testin,
> > file="testin",format="ENVI",datatype="INT2U",bandorder="BIL",overwrite=TRUE)
> >
> > but get an image with BSQ order
> > (rda object: https://www.dropbox.com/s/or5h7yb9nd52e94/testin.rda?dl=0)
>
> Which version of GDAL is under all of this? It doesn't matter here, but
> might have mattered.
>
> raster::writeRaster() puts interleave = bsq in the *.hdr files. "BIP" and
> does not seem to do anything. However:
>
> writeGDAL(as(testin, "SpatialGridDataFrame"), fname="testinsp.envi",
> drivername="ENVI", type="UInt16", options="INTERLEAVE=BIL",
> setStatistics=TRUE)
>
> yields interleave = bil in the *.hdr file. Using the same route, I get:
>
> writeRaster(testin, file="testin", format="ENVI", datatype="INT2U",
> options="INTERLEAVE=BIL", overwrite=TRUE)
>
> with interleave = bil in the *.hdr file. I'm not sure where
> raster::writeRaster() drops the options definitions given in bandorder=,
> maybe ENVI is not a 'native' file format?
>
> Hope this helps,
>
> Roger
>
>
> > Thanks
> > Agus
> >
> > R version 3.5.0 (2018-04-23)
> > Platform: x86_64-pc-linux-gnu (64-bit)
> > Running under: Debian GNU/Linux buster/sid
> >
> > Matrix products: default
> > BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
> > LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0
> >
> > locale:
> > [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C
> > LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8
> > LC_MONETARY=en_GB.UTF-8
> > [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C
> >               LC_ADDRESS=C               LC_TELEPHONE=C
> > [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
> >
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> > other attached packages:
> > [1] raster_2.7-15 rgdal_1.3-6   sp_1.3-1
> >
> >
> > Agus
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo using r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
> https://orcid.org/0000-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list