Re: [gdal-dev] Clipping an image via Python API problems

2011-11-28 Thread Graeme Merrall
Excellent. Thanks folks for your helpful replies Cheers, Graeme On Tue, Nov 29, 2011 at 6:01 AM, Even Rouault wrote: > Le lundi 28 novembre 2011 07:44:26, Chaitanya kumar CH a écrit : > > I should have said that you need to copy all bands 'individually'. > > Well, ReadAsArary() and WriteArray()

Re: [gdal-dev] Clipping an image via Python API problems

2011-11-28 Thread Even Rouault
Le lundi 28 novembre 2011 07:44:26, Chaitanya kumar CH a écrit : > I should have said that you need to copy all bands 'individually'. Well, ReadAsArary() and WriteArray() also exist at the dataset level and will read/write all bands. See : $ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:4

Re: [gdal-dev] Clipping an image via Python API problems

2011-11-27 Thread Chaitanya kumar CH
I should have said that you need to copy all bands 'individually'. On Mon, Nov 28, 2011 at 11:35 AM, Graeme Merrall wrote: > I've discovered that he bands are determined by the args to > driver.Create() that is if I create a 4 band image then the bands are > correct, however if I'm going to copy

Re: [gdal-dev] Clipping an image via Python API problems

2011-11-27 Thread Graeme Merrall
I've discovered that he bands are determined by the args to driver.Create() that is if I create a 4 band image then the bands are correct, however if I'm going to copy the image chunk around using ReadAsArray and WriteArray, doesn't it mean I need to retreive each band in turn? Or have I missed som

Re: [gdal-dev] Clipping an image via Python API problems

2011-11-27 Thread Chaitanya kumar CH
Graeme, You do need to copy all bands. Also, make sure you set the correct number of bands while creating the destination dataset. Color interpretation is useful when you have multiple bands. If you want to show your image in red, set it to GCI_PaletteIndex and set a colortable. On Mon, Nov 28,

[gdal-dev] Clipping an image via Python API problems

2011-11-27 Thread Graeme Merrall
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 from osgeo import gdal import numpy img = gdal.Open("original.tif") geotransform = img.GetGeoTransform() band1 = img.GetRasterBand(