I am working with the v2.3.3 NuGet of GDAL by Tamas Szekeres for the .NET environment, and can successfully open the etopo1_ice_g_f4.flt raster to cut basic tiles.
The problem I am having is that even when I apply the -r bilinear
option to my translation options, the generated image remains pixelated.
Specifically, I make the following calls in code to get the initial raster (simplifying the file names for this example):
GdalConfiguration.ConfigureGdal();
var etopoPath = @"F:\testing\etopo1_ice_g_f4.flt";
var colorPath = @"F:\testing\color.txt";
var pngPath = @"F:\testing\tile.png";
var tifPath = @"F:\testing\tile.tif";
var raster = Gdal.Open(etopoPath, Access.GA_ReadOnly);
I then set the appropriate projection extents, which will produce a 256×256 tile (in OpenMaps, it would be tile x = 306, tile y = 389, zoom = 10):
// shows us tile 306 389 z10
const double lonWest = -72.42;
const double lonEast = -72.02;
const double latNorth = 39.64;
const double latSouth = 39.24;
I set up the gdal_translate
options to include bilinear interpolation:
var translateOptions = new[] {
"-of", "GTiff",
"-projwin", $"{lonWest}", $"{latNorth}", $"{lonEast}", $"{latSouth}",
"-outsize", "256 256",
"-r", "bilinear",
"-q"
};
Gdal.wrapper_GDALTranslate(tifPath, raster, new GDALTranslateOptions(translateOptions), null, null);
And finally, process the GeoTIFF as a color-relief tile:
var demOptions = new[] {
"-of", "PNG",
"-q"
};
var tifRaster = Gdal.Open(tifPath, Access.GA_ReadOnly);
Gdal.wrapper_GDALDEMProcessing(pngPath, tifRaster, "color-relief", colorPath, new GDALDEMProcessingOptions(demOptions), null, null);
And it works, producing the following PNG image:
Now, the problem is that this does not seem to have been interpolated. The same image is produced even when -r bilinear
is removed from the options.
Using the same elevation data (etopo1), and doing my own bilinear interpolation processing, I get this image:
I would like to not have to get the raw elevation data and do my own bilinear interpolation… I'd rather have the image properly interpolated coming out of gdal_translate.
So, am I missing something?
Best Answer
I sorted out the issue. The etopo1 FLT file did not have a defined datum, so the GDAL interpolation failed. Fully answered here, in my second question on this topic.