[R-sig-Geo] writeRaster error: unknown file format

Roger Bivand Roger.Bivand at nhh.no
Fri Jan 24 13:34:17 CET 2014


On Fri, 24 Jan 2014, pecardoso wrote:

> I'm getting an error with writeRaster with apparent no particular reason.
>
> The procedure I'm following:
>
> *1. *reading an original landsat OLI band (TIF) downloaded from
> http://earthexplorer.usgs.gov/
>
> band <- raster(file.path(dir.work, 'LC81810682013122LGN01_B2.tif'), package
> = "raster")
>
> band
> class       : RasterLayer
> dimensions  : 7311, 7521, 54986031  (nrow, ncol, ncell)
> resolution  : 30, 30  (x, y)
> extent      : 370485, 596115, -1388715, -1169385  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=utm +zone=33 +datum=WGS84 +units=m +no_defs +ellps=WGS84
> +towgs84=0,0,0
> data source :
> D:\Dropbox\Kumbira2010\Landsat\LC81810682013122LGN01\LC81810682013122LGN01_B2.tif
> names       : LC81810682013122LGN01_B2
> values      : 0, 65535  (min, max)
>
> *2. *crop band to a given extent
> myext <- extent(c(416985, 425295, -1241505, -1226985))
> cropb <- crop(band, myext)
> dataType(cropb)
> [1] "INT2U # just like the original
>
> *3. *Write IDRISI raster file
> writeRaster(band2.ae, filename = file.path(tempdir(),'cropb.rst'), format =
> 'IDRISI', overwrite = TRUE)
>
> Error in .setFileExtensionHeader(filename, filetype) :
>  unknown file format

Did you follow the advice on:

?writeRaster

and run:

writeFormats()

to see which drivers are available on your platform? Hint:

http://www.gdal.org/formats_list.html

shows that the Idrisi raster format is called "RST".

Also, everything is always clearer when run in an R console interactively, 
not through R Studio. R Studio assumes that you know what you are doing 
when coding/scripting, something that doesn't apply to anyone I've met, 
especially including myself.

Hope this clarifies,

Roger

>
> Running from RStudio Version 0.98.490
>> sessionInfo()
> R version 3.0.2 (2013-09-25)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
>
> I get the same behaviour with raster 2.2-5 package
> locale:
> [1] LC_COLLATE=Portuguese_Portugal.1252  LC_CTYPE=Portuguese_Portugal.1252
> [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
> [5] LC_TIME=Portuguese_Portugal.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] rgdal_0.8-14  raster_2.2-12 sp_1.0-14
>
> loaded via a namespace (and not attached):
> [1] grid_3.0.2      lattice_0.20-24 tools_3.0.2
>
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/writeRaster-error-unknown-file-format-tp7585627.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at 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; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list