[gdal-dev] Clipping an image via Python API problems
Even Rouault
even.rouault at mines-paris.org
Mon Nov 28 14:01:19 EST 2011
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)
More information about the gdal-dev
mailing list