[gdal-dev] band overview into numpy array how-to?
Frank Warmerdam
warmerdam at pobox.com
Sat Jul 19 11:45:33 EDT 2008
Antonio Valentino wrote:
> Il giorno Sat, 19 Jul 2008 09:39:04 +0700
> "Yann Chemin" <yann.chemin at gmail.com> ha scritto:
>
>> Hi I am trying to get an image into a numpy array (for later display
>> in wx.Image)
>>
>> it is to have a view of the image at a screen size resolution more or
>> less. Due to the nature of the images (large size),
>> it will be easier to interact with overviews for display.
>> How can I load an overview into a numpy array?
>
> gdal.Band.GetOverview(self, ov_index) --> RasterBand instance
>
> gdal.Band.ReadAsArray(self, xoff=0, yoff=0, win_xsize=None,
> win_ysize=None, buf_xsize=None, buf_ysize=None, buf_obj=None)
>
Yann,
I would add that ReadAsArray() will automatically make use of available
overviews if buf_xsize/buf_ysize are less than win_xsize/win_ysize as
appropriate. So generally, just use ReadAsArray() to request your desired
region and indicate the reduced resolution you want to load it at, and
the overviews will be used when appropriate and available.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the gdal-dev
mailing list