Hi all,

I'd like to do some cropping based on pixel coordinates in a script I'm
writing.  I'm familiar with using the srcwin option to gdal_translate, but
have not done this using the API before.  Reading the API docs and some of
the previous postings to this list, it appears that the RasterIO function is
exposed in the Python API via band.ReadRaster().  I'd like some confirmation
that I'm understanding the docs correctly.

Assuming that I have an 8bit, paletted image named "foo.png", if I wanted to
extract a 50 x 50 pixel tile that had it's origin at pixel coords (0,0), I
would do something like this:

in_ds = gdal.Open('foo.png')
band = dataset.GetRasterBand(1)
tile_data = band.ReadRaster( 0, 0, 50, 50, 2500, 1, GDT_Byte )

and then I would imagine I have to create the output dataset and write
tile_data to it.

Is there a way to do specify the output dataset in such a way that it
matches all the params of the input data, but just contains the smaller data
area?

Roger
--
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to