I need to create a sample console application on c++ that will use *.hdf file as an input and will read it.
As I got, I need a GDAL library. I've found a GDAL tutorial on official GDAL website, but it's splitted on unended parts, so I can't find a good working example of use.
Can someone provide it to me?
Also I have some troubles with the GDAL library. As I found, I need the stable library from gisinternals, yep?
Best Answer
Here's just the nuts-and-bolts from some working code:
This code gets the value of one cell in a block in the raster.. the original raster was over 2TB as IMG so I couldn't read the whole thing into memory but I needed to do operations within a specified AOI which is translated to ColOff,RowOff and ReadCols by ReadRows rather than trying to read each cell directly from the source raster.
As I said in my comments it is important to set your paths and also add the additional dependency gdal_i.lib or the code will not link properly:
Creating/Writing raster is also fairly straightforward:
This code is missing about 500 lines between creating the memory (AccumData) and writing it - but that's not important in this context. Just remember that you need to address in Col,Row from this current block when modifying values in the memory and you should be fine.
When you download GDAL be sure to download the source, in the tools folder there are some spectacular examples of how to use GDAL that I used as a learning aid, you should find some value in them too.
In Visual Studio (this example from 2010) you need to set some properties in your project: To ensure that the compiler/linker can find the inputs that it needs.