An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110913/396e5bb6/attachment.pl>
Convert some value to NaN (GeoTiff)
2 messages · Joel Risso, Carsten Neumann
1 day later
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