Message-ID: <4E70ADAF.3050509@aol.com>
Date: 2011-09-14T13:35:43Z
From: Carsten Neumann
Subject: Convert some value to NaN (GeoTiff)
In-Reply-To: <CABz4_ftz3ZEiML8k-QCk3e8dfh0Yws3xLeyU632t8AiZLBenRw@mail.gmail.com>
Am 13.09.2011 06:32, schrieb Joel Risso:
> Dear All,
> I am new to spatial stats in R.
> I would be grateful if someone could help me in a script to convert some
> pixels' values (e.g. NoData, 0, etc.) to NaN in a Geotiff input.
> Thank you,
> Joel
>
Dear Joel,
there is a quit simple way using raster package.
read GTiff: a<-raster('H:\\example.tif')
setting NA values: NAvalue(a)<-0 (here you define which value within
your image should become a no data value)
or if you want a character string called "NaN" you can do:
d<-which (getValues(a) == 0)
a[d]<-"NaN"
I hope this helps.
Best regards
Carsten