Hi Michael,

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 xml.etree.ElementTree.XML
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.

Anton

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:
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
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to