[gdal-dev] read whole elevation data from geotif to vector[x][y]
Mateusz Łoskot
mateusz at loskot.net
Tue Jun 17 12:45:41 PDT 2014
On 17 June 2014 20:56, Robert Grah <smilingmolecule at web.de> wrote:
>
> I try to read the whole elevation data from a band of a GeoTiff image into a c++ 2d vector so that I can read the values like vector[x][y].
> [...]
> Is there an easy way to get the values ordered like the pixels of an image?
> From left to right and top to bottom? I think i am overlooking something...
I think, your image is read correctly into vector of vectors,
but you are mismatching x and y indices while accessing individual pixels.
Compare your technique of accessing with this simple example:
// image 3x4
std::vector<std::vector<int>> v =
{
{ 1, 2, 3, 4 },// scanline 0
{ 5, 6, 7, 8 },// scanline 1
{ 9,10,11,12 } // scanline 2
};
std::size_t y(1), x(2);
int pixel = v[y][x]; // value 7
Notice, it is v[y][x]. no v[x][y].
Best regards,
--
Mateusz Łoskot, http://mateusz.loskot.net
More information about the gdal-dev
mailing list