[gdal-dev] python downsample API?
anton.korosov at nersc.no
Wed Apr 11 11:10:23 EDT 2012
I do that maybe in an awkward way but it saves time.
1. I create a VRT file (e.g. using CreateCopy) and open it using
2. I decrease rasterXSize and rasterYSize attributes of the VRTDataset tag
3. I also decrease xSize and ySize attributes of the DstRect tag
4. Then I save the VRT and open it again using gdal.Open
5. When I use ReadAsArray it downscales the matrix automatically
Unfortunately I cannot provide the code in a single piece - it is
dissolved in a large package.
On 04/11/2012 04:31 PM, K.-Michael Aye 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:
> 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,
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
More information about the gdal-dev