[gdal-dev] gdalwarp's default nodata value
Even Rouault
even.rouault at mines-paris.org
Wed May 12 18:03:32 EDT 2010
Le Wednesday 12 May 2010 23:15:08 Joaquim Luis, vous avez écrit :
> Even,
>
> Thanks, I understand it better now and made some advances but I'm still
> facing some troubles.
>
> For example, if I do this
>
> papszWarpOptions = CSLSetNameValue(papszWarpOptions, "INIT_DEST", "300" );
> psWO->papszWarpOptions = CSLDuplicate(papszWarpOptions);
>
> than it works fine.
>
> However, if I do (remember that I want NaNs)
>
> papszWarpOptions = CSLSetNameValue(papszWarpOptions, "INIT_DEST", "nan" );
>
> than I get zeros again in place of the nodata.
Works for me. You'll have to use your debugger I'm afraid
> The link you pointed me says
>
> "...or INIT_DEST=NO_DATA: This option forces the destination image to be
> initialized to the indicated value (for all bands) or indicates that it
> should be initialized to the NO_DATA value in
> padfDstNoDataReal/padfDstNoDataImag."
>
>
> So I next tried
>
> papszWarpOptions = CSLSetNameValue(papszWarpOptions, "INIT_DEST", "NO_DATA"
> ); ...
> psWO->padfSrcNoDataReal = (double *)
> CPLMalloc(psWO->nBandCount*sizeof(double)); psWO->padfSrcNoDataImag =
> (double *) CPLMalloc(psWO->nBandCount*sizeof(double)); for (i = 0; i <
> nBands; i++) {
> psWO->padfSrcNoDataReal[i] = 500.;
> psWO->padfSrcNoDataImag[i] = 0.0;
> GDALSetRasterNoDataValue( GDALGetRasterBand(hDstDS, i+1),
> pdfDstNodata[0]); }
Hum, do you realize that you set padfSrcNoDataReal ? INIT_DEST=NO_DATA will
fetch from padfDstNoDataReal as stated in the above doc...
> I tried to see what gdalwarp does ... and another problem. What is this?
>
> gdalwarp -of netCDF -s_srs "+proj=latlong" -t_srs "+proj=utm +zone=29
> +datum=WGS84" swath_grid.grd lixo_utm.grd
> Output driver `netCDF' not recognised or does not support
> direct output file creation. The following format drivers are configured
> and support direct output:
Read the error message again ;-) "does not support direct output file
creation"--> netCDF driver indeed only supports CreateCopy(), not Create()
(--> random access) which is required by gdalwarp.
The drivers that are supported as output driver for gdalwarp will have a '+'
in the output of gdalinfo --formats. Look at the difference betwenn GeoTIFF
and netCDF:
GTiff (rw+v): GeoTIFF
netCDF (rw): Network Common Data Format
More information about the gdal-dev
mailing list