Mathieu,

The error message says that something is going wrong when writing the
results to disk. This smells like bug, but it is almost certainly because
there is no more disk space available in your temp folder/disk. To avoid
using a temp file (used for large files only), you can use calc with a
filename

elev <- calc(detm, function(x)  x[,2] - x[,1] ,
filename=''x:/elevation.tif")

You can also change the temp folder (see showOptions / setOptions)  to a
disk with more space, and then perhaps use the below notation (unstack was
redundant):

elev <- detm[[2]] - detm[[1]]


Robert


> dem <- unstack(detm)[[1]]

> dtm <- unstack(detm)[[2]]
> elev <- dem - dtm
(the above message)
> ncell(dem)==ncell(dtm)
[1] TRUE
> extent(dem)==extent(dtm)
[1] TRUE
> res(dem)==res(dtm)
[1] TRUE TRUE




On Wed, Nov 9, 2011 at 6:39 AM, Mathieu Rajerison <
mathieu.rajerison@gmail.com> wrote:

> Hi,
>
>
> I have a RasterStack detm composed of a dem and a dtm.
>
> I wanted to apply the difference between dem and dtm so as to get the
> elevation.
>
> But I got the following message (in French):
> Erreur dans result[, i] <- readBin(raster@file@con, what = dtype, n =
> ncols, :
> le nombre d'objets à remplacer n'est pas multiple de la taille du
> remplacement
> De plus : Messages d'avis :
> 1: fermeture de la connexion inutilisée 4
>
> (C:/DOCUME~1/MATHIE~1.RAJ/LOCALS~1/Temp/R_raster_tmp/raster_tmp_310457192102.gri)
>
> 2: fermeture de la connexion inutilisée 3
>
> (C:/DOCUME~1/MATHIE~1.RAJ/LOCALS~1/Temp/R_raster_tmp/raster_tmp_79244111022.gri)
>
> Also, I got an error message telling me I had low disk space...
>
> Here is the complete code:
>
> > dem <- unstack(detm)[[1]]
>
> > dtm <- unstack(detm)[[2]]
> > elev <- dem - dtm
> (the above message)
> > ncell(dem)==ncell(dtm)
> [1] TRUE
> > extent(dem)==extent(dtm)
> [1] TRUE
> > res(dem)==res(dtm)
> [1] TRUE TRUE
>
> Does anyone see where the problem is?
>
>
> Thanks in advance,
>
> Mathieu
>
>        [[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]]

