<div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); ">The smallest almost working code chunk I have right now is below. This is taaking a 40k by 40k and pulling out the top left quarter. The original has 4 bands - RGBA</div>
<div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); "><br></div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); ">
<div>from osgeo import gdal</div><div>import numpy</div><div>img = gdal.Open("original.tif")</div><div>geotransform = img.GetGeoTransform()</div><div>band1 = img.GetRasterBand(1)</div><div><br></div><div>driver = gdal.GetDriverByName("GTiff)</div>
<div># coordinates will be calculated but hardcoded for now</div><div>dst = driver.Create('sliver.tif', 20000, 20000, 1, gdal.GDT_Byte)</div><div>dst.SetProjection(img.GetProjection())</div><div>scanline1 = band1.ReadAsArray(0, 0, 20000, 20000)</div>
<div>dst.GetRasterBand(1).WriteArray(scanline1)</div><div><br></div><div>Should I be looping through each band and reading/writing to the image? I'm assuming yes</div><div><br></div><div>Also. band 1 of the original image is red but in the new image the band color is grey. I've tried a few variations with GDALRasterBand.SetColorInterpretation() with no luck. What have I missed?</div>
<div><br></div><div>Cheers,</div></div>