Last active
April 29, 2016 12:48
-
-
Save perrygeo/07ce04fe886d1c8090ab1b22d7579396 to your computer and use it in GitHub Desktop.
GDAL IO Error on Decimated reads on alpha band
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "gdal.h" | |
#include "cpl_conv.h" /* for CPLMalloc() */ | |
/* | |
* compile with | |
* gcc `gdal-config --cflags` `gdal-config --libs` -o test test.c | |
* | |
*/ | |
/* | |
* For test dataset `alpha.tif` | |
* https://github.com/mapbox/rasterio/raw/issue-679/tests/data/alpha.tif | |
* | |
*/ | |
/* | |
* Results w/ GDAL 2.x | |
* | |
Reading band 1 into 735x735 | |
completed | |
Reading band 1 into 734x734 | |
completed | |
Reading band 2 into 735x735 | |
completed | |
Reading band 2 into 734x734 | |
completed | |
Reading band 3 into 735x735 | |
completed | |
Reading band 3 into 734x734 | |
completed | |
Reading band 4 into 735x735 | |
completed | |
Reading band 4 into 734x734 | |
ERROR 1: IReadBlock failed at X offset 0, Y offset 0 | |
completed | |
*/ | |
int main() | |
{ | |
GDALDatasetH hDataset; | |
GDALAllRegister(); | |
GDALDriverH hDriver; | |
GDALRasterBandH hBand; | |
double adfGeoTransform[6]; | |
char *pafScanline; | |
int bandnum; | |
int outX; | |
int outY; | |
int nXSize; | |
int nYSize; | |
hDataset = GDALOpen( "alpha.tif", GA_ReadOnly ); | |
if( hDataset == NULL ) { | |
exit(1); | |
} | |
for ( bandnum = 1; bandnum <= 4; bandnum++ ) { | |
hBand = GDALGetRasterBand( hDataset, bandnum ); | |
nXSize = GDALGetRasterBandXSize( hBand ); | |
nYSize = GDALGetRasterBandYSize( hBand ); | |
outX = 735; | |
outY = 735; | |
pafScanline = (char *) CPLMalloc(sizeof(char) * outX * outY); | |
printf("Reading band %d into %dx%d\n", bandnum, outX, outY); | |
GDALRasterIO( hBand, GF_Read, 0, 0, nXSize, nYSize, | |
pafScanline, outX, outY, GDT_Byte, | |
0, 0 ); | |
printf(" completed\n"); | |
outX = 734; | |
outY = 734; | |
pafScanline = (char *) CPLMalloc(sizeof(char) * outX * outY); | |
printf("Reading band %d into %dx%d\n", bandnum, outX, outY); | |
GDALRasterIO( hBand, GF_Read, 0, 0, nXSize, nYSize, | |
pafScanline, outX, outY, GDT_Byte, | |
0, 0 ); | |
printf(" completed\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dataset info