Gianni,
Would you be able to create a reproducible example that shows this?
This is what I get:


>
> library(raster)
Loading required package: sp
raster version 1.9-45 (22-November-2011)
> library(rgdal)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.7.2, released 2010/04/23
Path to GDAL shared files: C:/soft/R/R-2.14.0/library/rgdal/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470]
Path to PROJ.4 shared files: C:/soft/R/R-2.14.0/library/rgdal/proj
>
> r <- raster(nc=10, nr=10, xmn=0, xmx=10, ymn=0, ymx=10)
> r[] = 1:100
> r[1:10] = NA
> x <- writeRaster(r, 'test.asc', overwrite=TRUE)
> readLines('test.asc', 6)[6]
[1] "NODATA_value -9999 "
>
> x <- writeRaster(r, 'test2.asc', NAflag=-10, overwrite=TRUE)
> readLines('test2.asc', 6)[6]
[1] "NODATA_value -10 "
>
> x
class       : RasterLayer
dimensions  : 10, 10, 100  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 10, 0, 10  (xmin, xmax, ymin, ymax)
coord. ref. : NA
values      : C:\Documents and Settings\rhijmans\My Documents\test2.asc
min value   : -2147483648
max value   : 2147483647

>
> x = setMinMax(x)
> x
class       : RasterLayer
dimensions  : 10, 10, 100  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 10, 0, 10  (xmin, xmax, ymin, ymax)
coord. ref. : NA
values      : C:\Documents and Settings\rhijmans\My Documents\test2.asc
min value   : 11
max value   : 100

>
> sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C

[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rgdal_0.7-1   raster_1.9-45 sp_0.9-91

loaded via a namespace (and not attached):
[1] grid_2.14.0    lattice_0.20-0
>
>
>

Robert


On Wed, Nov 23, 2011 at 4:59 PM, gianni lavaredo
<gianni.lavaredo@gmail.com>wrote:

> Dear Researchers,
>
> I am using the function rasterize to create a map with mean value and
> NAvalue
> pixel (where I have no points), I saved two format GeoTif and ASCII but
> after open in ArcMap in the ASCII file the NAvalue pixel are - 3 (and not
> NODATA ) as the TIF format (always in Arcmap). I tried to set up for both
> images NAflag=-9999.
>
> thanks in advance
> Gianni
>
> Mydata  <- read.delim("Mydata.txt", sep=",",header=TRUE)
> coordinates(Mydata) =~X+Y
> r = raster(extent(Mydata))
> res(r) = 0.5
> r.mean <- rasterize(Mydata, r, 'Z', fun=mean)
> NAvalue(r.mean)
> [1] -3.4e+38
>
> rt <- writeRaster(r.mean, filename="MeanHeigh.tif", format="GTiff",
> overwrite=TRUE, NAflag=-9999)
> rt
> class       : RasterLayer
> dimensions  : 1659, 2810, 4661790  (nrow, ncol, ncell)
> resolution  : 0.5, 0.5  (x, y)
> extent      : 267586.6, 268991.6, 4147061, 4147890  (xmin, xmax, ymin,
> ymax)
> projection  : NA
> values      : C:/MySAMPLE/MeanHeigh.tif
> min value   : 1332.69
> max value   : 1744.35
>
>
> rt <- writeRaster (r.mean, "MEANHeigh.asc", format="ascii", overwrite=T,
> datatype="INT4S",NAflag=-9999)
> rt
> class       : RasterLayer
> dimensions  : 1659, 2810, 4661790  (nrow, ncol, ncell)
> resolution  : 0.5, 0.5  (x, y)
> extent      : 267586.6, 268991.6, 4147061, 4147890  (xmin, xmax, ymin,
> ymax)
> projection  : NA
> values      : C:/MYSAMPLE/MeanHeigh.asc
> *min value   : -3 *
> max value   : 1744
>
>        [[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]]

