On Sat, 21 Nov 2009, Paul Hiemstra wrote:

Hi Ned,

Is it an option to switch to another GDAL format, GTiff for example? Check if this exports the NA values correctly. Not really an answer to your question, but maybe a helpful suggestion.

cheers and good luck,
Paul

Ned Horning wrote:
I am trying to export a SpatialPixelsDataFrame object with floating point values to an ASCII grid file and want to specify a nodata value. I tried write.asciigrid from the sp package and I couldn't figure out how to output float values. The pixel values exported as integers.

For now I am using the following writeGDAL statement:
--
writeGDAL(sp_hsm_pard, out_pard, drivername="AAIGrid", type="Float32", options="DECIMAL_PRECISION=3", "NODATA=-9999")

Maybe reading:

args(writeGDAL)
function (dataset, fname, drivername = "GTiff", type = "Float32",
    mvFlag = NA, options = NULL, copy_drivername = "GTiff")

would help?

You are getting:

dataset=sp_hsm_pard, fname=out_pard, drivername="AAIGrid", type="Float32", options="DECIMAL_PRECISION=3", mvFlag="NODATA=-9999"

by argument names and positions, I think, where internally as.double("NODATA=-9999") is being coerced to an NA (a warning may have been shown.

Perhaps try setting mvFlag=-9999? If you wanted to put it in the options, that may work, but as.double(mvFlag) is explicitly set as the no-data value on the band(s) being written in create2GDAL() inside writeGDAL().

Hope this helps,

Roger



--
This appears to output the image okay but it is not assigning the proper values to NODATA_value. The NODATA_value in the exported file is "1" instead of "-9999".

Can someone let me know how to output floating point data to an ESRI ASCII grid file and specify a nodata value.

Thanks,

Ned

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo




--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to