I have an ESRI ASCII file of the form:
ncols 5
nrows 4
xllcorner 0
yllcorner 0
cellsize 10
NODATA_value -9999
25.4 26.1 27 28.6 27.7
25 26 26.4 27.9 27.4
25.1 25.8 26.8 28.6 27.6
27.5 28 27.7 30.6 28.3
And I need to use libtiff.net ( or its C++ equivalent, libtiff, or libgeotiff, or GDAL, or any other C# or C++ libraries) to convert it to a geotiff file.
But I simply don't know what are the fields to set, there are a lot of fields such as TIFFTAG_IMAGEWIDTH, TIFFTAG_SAMPLESPERPIXEL or TIFFTAG_BITSPERSAMPLE which I don't know whether they are relevant or not.
Given an ESRI ASCII file as per above, how to use the libtiff.net or libtiff library to create a geotiff file?
Why am I doing this?
In my application, I have a mesh, and I would have to convert the mesh to a raster file. I want to create such a geotiff raster file directly from the mesh sampling, without creating an intermediate ASCII file first because the intermediate file size is very big compared to the final geotiff output file.
The only approach I can think of is to directly manipulate the geotiff file using libtiff.net while I am obtaining the grid points on the mesh.
How to do this, or is there a better approach?
Actually this task can be easily done by using GDAL library ( or its .Net equivalent, GDAL.Net). There is even an example here in Python:
And the Python script:
Converting the code to .Net should be trivial enough.