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

Graeme Merrall graeme at inetix.com.au
Mon Nov 28 18:52:10 EST 2011


Excellent. Thanks folks for your helpful replies

Cheers,
 Graeme

On Tue, Nov 29, 2011 at 6:01 AM, Even Rouault
<even.rouault at mines-paris.org>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() 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:41)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from osgeo import gdal
> d = gdal.Open('../autotest/gcore/data/rgbsmall.tif')
> >>> d.ReadAsArray()
> array([[[  0,   0,   0, ...,  84,  89,  92],
>        [  0,   0,   0, ..., 104,  94,  90],
>        [  0,   0,   0, ...,  95,  96,  81],
>        ...,
>        [  0,   0,   1, ...,  18,  43,  34],
>        [  0,   0,   0, ...,  18,  22,  21],
>        [  0,   0,   0, ...,  12,  15,  14]],
>
>       [[  0,   0,   0, ..., 124, 138, 146],
>        [  0,   0,   0, ..., 145, 141, 139],
>        [  0,   0,   0, ..., 136, 140, 125],
>        ...,
>        [  0,   0,   1, ...,  46,  67,  54],
>        [  0,   0,   0, ...,  43,  42,  39],
>        [  0,   0,   0, ...,  37,  35,  32]],
>
>       [[  0,   0,   0, ...,  28,  31,  34],
>        [  0,   0,   0, ...,  49,  39,  32],
>        [  0,   0,   0, ...,  42,  43,  27],
>        ...,
>        [  0,   0,   1, ...,  50,  71,  61],
>        [  0,   0,   0, ...,  48,  51,  51],
>        [  0,   0,   0, ...,  44,  46,  46]]], dtype=uint8)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111129/653bb328/attachment-0001.html


More information about the gdal-dev mailing list