[gdal-dev] read whole elevation data from geotif to vector[x][y]
Robert Grah
smilingmolecule at web.de
Tue Jun 17 11:56:43 PDT 2014
Hallo,
i think this question is somehow a bit stupid but I have to ask it anyway because i can not find a good working solution.
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].
I also like to convert the data to an image and perform other operations.
I tried it like this, but this gives me the data in a strange order:
poBand->RasterIO( GF_Read, 0, 0, nXSize, nYSize,
pafScanline2, nXSize, nYSize, GDT_Float32,
0, 0 );
int totalCount = 0;
for (int i = 0; i GetXSize(); i++){
vector yVal;
for (int j = 0; j GetYSize(); j++){
yVal.push_back(pafScanline2[totalCount]);
totalCount++;
}
altData.push_back(yVal);
}
I also tried to read every single value step by step, but this was really slow.
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...
Cheers,
Robert
More information about the gdal-dev
mailing list