[gdal-dev] python downsample API?

Scott Arko saarko at alaska.edu
Wed Apr 11 14:17:56 EDT 2012


Hi Michael,


I may be missing your question, but why aren't you just using ReadAsArray?
 It has an option to return a smaller array from the input array.  Now, I'm
not sure how it does the resampling (you could look to see), but you can
make a call like

data =
banddata.ReadAsArray(0,0,filehandle.RasterXSize,filehandle.RasterYSize,xsize,ysize)

where xsize and ysize are smaller than the true RasterXSize or RasterYSize.
 I haven't looked at this in a while, but I'm pretty sure this will work.
 Did I miss the point of what you were asking?


Thanks,
Scott


On Wed, Apr 11, 2012 at 6:31 AM, K.-Michael Aye <kmichael.aye at gmail.com>wrote:

> Dear all,
>
> is there a Python API for downsampling a huge dataset?
> What I would like to do:
>
> * get my dataset
> * read out RasterXSize and RasterYSize
> * calculate how many lines and rows I need to skip to get a quick overview
> image, e.g. 10 lines to skip.
> * Have a ReadAsArray interface where I can say something like this:
> ** data = ds.ReadAsArray(xoffset, yoffset, 10000, 10000, skipping=10)
>
> which in numpy terms would give me every 10nth line like this:
> array[:,:,10]
>
> I really don't need quality at all, just speed, for a rough overview for
> further zooming in with lassos, as the images I deal with sometimes have
> more than 200 MPixels.
>
> Is this possible in Python?
> I was thinking now, maybe one could use numpy's memmap somehow for this,
> don't know much about it, though…
>
> Thanks for any hints!
>
> Best regards,
> Michael
>
>
> ______________________________**_________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/gdal-dev<http://lists.osgeo.org/mailman/listinfo/gdal-dev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120411/0a748615/attachment.html


More information about the gdal-dev mailing list