Skip to main content
Notice removed Authoritative reference needed by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Notice added Authoritative reference needed by root676
Bounty Started worth 50 reputation by root676
Tweeted twitter.com/StackGIS/status/1317978795249455104
Source Link
root676
  • 2.4k
  • 2
  • 26
  • 31

Reading raster backward using GDAL

I am currently working on two-scan raster algorithms (euclidean distance transformations, cost surface analysis, etc.). Those algorithms require a line-wise forward raster scan (from top left to bottom right) as well as a backward/reversed raster scan (from bottom right to top left).

I am currently using GDAL to read the raster data using the C++ code provided by the tutorial.

float *pafScanline; int nXSize = poBand->GetXSize(); pafScanline = (float *) CPLMalloc(sizeof(float)*nXSize); poBand->RasterIO( GF_Read, 0, 0, nXSize, 1, pafScanline, nXSize, 1, GDT_Float32, 0, 0 ); 

The RasterIo method reads the raster as scanlines into dynamically allocated memory (provided by CPLMalloc) and it does so from left to right. Up to now I did not find any GDAL methods to read a raster scanline from right to left (eg. backwards).

My question: Is there any better method to achieve a backwards raster scan than reading the scanline from left to right and then reorder the values (which would mean that the scanline has to be processed twice)?