Paulo, The first error message is perhaps ambiguous, but the last one is very clear: "No such file or directory". It suggests that either the path does not exist, or you are not allowed to write to it (from R).
Error in .local(.Object, ...) : Dataset copy failed Error in file(filename, "w") : cannot open the connection In addition: Warning message: In file(filename, "w") : cannot open file '/Users/paulobrando/Dropbox/R.projects/Xingu_Drought_2007/MODIS/MODIS_Temperature/maps/TEMP_2010_Xingu_AVG.asc': No such file or directory You can test with something like this: write.table(data.frame(x=1), file='~/Dropbox/R.projects/Xingu_Drought_2007/MODIS/MODIS_Temperature/maps/test.txt') Also, the examples that you say do work cannot be correct. You say you use: writeRaster(e,filename="~/Dropbox/R.projects/ex.tif", overwrite=TRUE) to get a RasterLayer with values : /Users/paulobrando/Documents/RS/MODISTemp/test.tif That is not possible. Best, Robert On Fri, Mar 30, 2012 at 6:18 AM, Paulo Brando <paulobra...@gmail.com> wrote: > Dear All, > > I'm getting an error when I try to write a raster to file. Please see more > details below. > > This example works: > > r <- raster(ncol=10, nrow=10) > > vals <- 1:ncell(r) > > r <- setValues(r, vals) > > > writeRaster(r, filename="teste.tif") > > This one also works, using only one layer from MODIS temperature product: > > > ex > > class : RasterLayer > > band : 1 > > dimensions : 720, 657, 473040 (nrow, ncol, ncell) > > resolution : 926.6254, 926.6254 (x, y) > > extent : -6150259, -5541466, -1667926, -1000755 (xmin, xmax, ymin, > ymax) > > coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 > +b=6371007.181 +units=m +no_defs > > values : > /Users/paulobrando/Documents/RS/MODISTemp/TEMP_2000_2010_Xingu_Monthly.grd > > min value : 18.85999 > > max value : 37.79999 > > layer name : layer.1 > > > > writeRaster(e,filename="~/Dropbox/R.projects/ex.tif", > overwrite=TRUE) > > class : RasterLayer > > dimensions : 720, 657, 473040 (nrow, ncol, ncell) > > resolution : 926.6254, 926.6254 (x, y) > > extent : -6150259, -5541466, -1667926, -1000755 (xmin, xmax, ymin, > ymax) > > coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 > +b=6371007.181 +units=m +no_defs > > values : /Users/paulobrando/Documents/RS/MODISTemp/test.tif > > min value : 18.85999 > > max value : 37.79999 > > layer name : test > > But when we I attempt use calc to take the average of a MODIS time-series, > I get an error: > > > sub.07 > > class : RasterLayer > > dimensions : 720, 657, 473040 (nrow, ncol, ncell) > > resolution : 926.6254, 926.6254 (x, y) > > extent : -6150259, -5541466, -1667926, -1000755 (xmin, xmax, ymin, > ymax) > > coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 > +b=6371007.181 +units=m +no_defs > > values : in memory > > min value : 24.935 > > max value : 43.112 > > layer name : layer > > > #trying to save as tif > > > writeRaster(sub.07, > > filename="~/Dropbox/R.projects/Xingu_Drought_2007/MODIS/MODIS_Temperature/maps/TEMP_2010_Xingu_AVG.tif", > > + overwrite=TRUE) > > Error in .local(.Object, ...) : Dataset copy failed > > > #trying to save as asc > > > writeRaster(sub.07, > > filename="~/Dropbox/R.projects/Xingu_Drought_2007/MODIS/MODIS_Temperature/maps/TEMP_2010_Xingu_AVG.asc", > > + overwrite=TRUE) > > Error in file(filename, "w") : cannot open the connection > > In addition: Warning message: > > In file(filename, "w") : > > cannot open file > > '/Users/paulobrando/Dropbox/R.projects/Xingu_Drought_2007/MODIS/MODIS_Temperature/maps/TEMP_2010_Xingu_AVG.asc': > No such file or directory > > > > I am running R on a mac. > > > sessionInfo() > > R version 2.14.2 (2012-02-29) > > Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) > > > locale: > > [1] C > > > attached base packages: > > [1] grid splines stats graphics grDevices utils datasets > > [8] methods base > > > other attached packages: > > [1] ncdf_1.6.6 rasterVis_0.10-9 hexbin_1.26.0 > > [4] latticeExtra_0.6-19 RColorBrewer_1.0-5 lattice_0.20-0 > > [7] raster_1.9-77 rgdal_0.7-8 sp_0.9-95 > > [10] Hmisc_3.9-2 survival_2.36-12 rj_1.0.3-7 > > > loaded via a namespace (and not attached): > > [1] cluster_1.14.2 rj.gd_1.0.3-3 tcltk_2.14.2 tools_2.14.2 zoo_1.7-7 > > [[alternative HTML version deleted]] > > _______________________________________________ > 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