Until we find a solution to this problem, you can use writeGDAL

writeGDAL(as(raster(matrix(1, 1, 1)), "SpatialGridDataFrame"), fname =
"test.tif") ## it works



On Tue, Dec 10, 2013 at 7:24 PM, Etienne B. Racine <etiennebr@gmail.com>wrote:

> I have the same problem: saving an unprojected raster as a .tif raises an
> error. To complete what Guillaume said:
>
> library("raster")
> # Fail :
> writeRaster(raster(matrix(1, 1, 1)), filename = "test.tif")
>
> # But,
> writeRaster(raster(matrix(1, 1, 1)), filename = "test.grd")
> # And
> r = raster()
> values(r) = 1
> writeRaster(r, filename = "test_projected.tif")
>
> #Are working fine.
>
> >sessionInfo()
> R version 3.0.2 (2013-09-25)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> [...]
>
> other attached packages:
> [1] rgdal_0.8-14  raster_2.1-66 sp_1.0-14
>
> loaded via a namespace (and not attached):
> [1] grid_3.0.2      lattice_0.20-24
>
> Etienne
>
>
> 2013/12/10 Guillaume Drolet <droletguillaume@gmail.com>
>
> > Hello,
> >
> > This morning I updated RStudio to version 0.98.484, and Quantum GIS to
> > version 2.0.1 (Dufour) using the standalone installer.
> >
> > After that, I tried to run some code in RStudio and I got the error
> message
> > below when running the following command:
> >
> > > filename <- "test.tif"
> > > try(writeRaster(raster(matrix(1, 1, 1)), filename = filename,
> overwrite =
> > > overwrite))
> >
> > Error in .gd_SetProject(transient, crs(r)) :
> >   STRING_ELT() can only be applied to a 'character vector', not a
> 'logical'
> >
> > Then, I updated rgdal to version 0.8-14 and now I get this error when
> > running the same code:
> >
> > Error in .gd_SetProject(object, ...) :
> >   STRING_ELT() can only be applied to a 'character vector', not a
> 'logical'
> >
> > Until this morning, I never had any problem with that line of code
> above. I
> > suspect this could be due to the QGIS installation that could have messed
> > with my GDAL installation: is that possible (is GDAL used by rgdal at
> all)?
> > I tried uninstalling QGIS but I still get the same error message.
> >
> > My session info:
> >
> > R version 3.0.2 (2013-09-25)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> >
> > locale:
> > [1] LC_COLLATE=French_Canada.1252  LC_CTYPE=French_Canada.1252
> > LC_MONETARY=French_Canada.1252
> > [4] LC_NUMERIC=C                   LC_TIME=French_Canada.1252
> >
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> > other attached packages:
> >  [1] fmask_0.1         RSAGA_0.93-6      plyr_1.8          shapefiles_0.7
> > foreign_0.8-55
> >  [6] gstat_1.0-18      data.table_1.8.10 rgdal_0.8-14      roxygen2_3.0.0
> > raster_2.1-68
> > [11] sp_1.0-14
> >
> > loaded via a namespace (and not attached):
> >  [1] brew_1.0-6       codetools_0.2-8  digest_0.6.3     grid_3.0.2
> > intervals_0.14.0 lattice_0.20-23
> >  [7] spacetime_1.0-9  stringr_0.6.2    tools_3.0.2      xts_0.9-7
> > zoo_1.7-10
> >
> > I will be very grateful of any help or piece of advice on how to fix that
> > or
> > where to look for clues.
> >
> > Best wishes,
> > Guillaume
> >
> >
> >
> > --
> > View this message in context:
> >
> http://r-sig-geo.2731867.n2.nabble.com/Error-in-gd-SetProject-transient-crs-r-tp7585330.html
> > Sent from the R-sig-geo mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Ahmadou H. DICKO
statistician economist (Ingénieur Statisticien Économiste)
PhD candidate in Climate change economics
Faculty of economics and managment - Cheikh Anta Diop University
West African Science Service Center on Climate Change and Adaptated Land
Use (WASCAL)
Center for Development Research (ZEF) - University of Bonn
email : ahmadou.dicko@ucad.edu.sn
twitter : @dickoah
github : github/dickoa <https://github.com/dickoa>
tel : +221 33 827 55 16
portable: +221 77 123 81 69

	[[alternative HTML version deleted]]

