I've written some simple Python code to flip a raster in relation to the y-axis. The raster is 20000x19459 and has 4 bands of type Byte, and is written east to west (I have no idea why). The script proceeds normally for the first 2 bands, but slows way down after starting band 3. I let it run overnight, and it had processed less than 1000 columnsin band 3, whereas the previous pace for bands 1&2 was around 1000 columns every 10 seconds. Here is the relevant code with a few debugging statements followed by the gdalinfo output. The only thing I'm noticing is that the input image is INTERLEAVED=BAND whereas the output is INTERLEAVED=PIXEL. Any help is appreciated.<div>
<br></div><div>------------------------------------------------------------------------------</div><div><div><div>for band in range(1, indataset.RasterCount + 1):</div><div> ## Print the current band</div><div> print 'Band %s' % band</div>
<div><br></div><div> inband = indataset.GetRasterBand(band)</div><div> outband = outdataset.GetRasterBand(band)</div><div><br></div><div> count = 0</div><div> print count</div><div><br></div><div> for i in range(inband.XSize):</div>
<div><br></div><div> ## print the current interval of 1k lines</div><div> new_count = int(i / 1000)</div><div> if new_count > count:</div><div> print new_count</div><div> count = new_count</div><div>
<br></div><div> inline = inband.ReadAsArray(i, 0, 1, inband.YSize)</div><div><br></div><div> outband.WriteArray(inline, inband.XSize - i - 1, 0)</div><div><br></div><div> inline = None</div><div> </div><div> inband = None</div>
<div> outband = None</div></div></div><div><br></div><div>------------------------------------------------------------------------------</div><div><div>Driver: GTiff/GeoTIFF</div><div>Files: test.tif</div><div>Size is 20000, 19459</div>
<div>Coordinate System is:</div><div>GEOGCS["WGS 84",</div><div> DATUM["WGS_1984",</div><div> SPHEROID["WGS 84",6378137,298.257223563,</div><div> AUTHORITY["EPSG","7030"]],</div>
<div> AUTHORITY["EPSG","6326"]],</div><div> PRIMEM["Greenwich",0],</div><div> UNIT["degree",0.0174532925199433],</div><div> AUTHORITY["EPSG","4326"]]</div>
<div>Origin = (-175.536864949200321,33.666235092496755)</div><div>Pixel Size = (-0.000062579160220,-0.000054370391310)</div><div>Metadata:</div><div> AREA_OR_POINT=Area</div><div>Image Structure Metadata:</div><div> INTERLEAVE=BAND</div>
<div>Corner Coordinates:</div><div>Upper Left (-175.5368649, 33.6662351) (175d32'12.71"W, 33d39'58.45"N)</div><div>Lower Left (-175.5368649, 32.6082416) (175d32'12.71"W, 32d36'29.67"N)</div>
<div>Upper Right (-176.7884482, 33.6662351) (176d47'18.41"W, 33d39'58.45"N)</div><div>Lower Right (-176.7884482, 32.6082416) (176d47'18.41"W, 32d36'29.67"N)</div><div>Center (-176.1626566, 33.1372384) (176d 9'45.56"W, 33d 8'14.06"N)</div>
<div>Band 1 Block=20000x1 Type=Byte, ColorInterp=Red</div><div> Mask Flags: PER_DATASET ALPHA</div><div>Band 2 Block=20000x1 Type=Byte, ColorInterp=Green</div><div> Mask Flags: PER_DATASET ALPHA</div><div>Band 3 Block=20000x1 Type=Byte, ColorInterp=Blue</div>
<div> Mask Flags: PER_DATASET ALPHA</div><div>Band 4 Block=20000x1 Type=Byte, ColorInterp=Alpha</div></div>