Hi,<br><br><div class="gmail_quote">2010/1/19 Roger André <span dir="ltr"><<a href="mailto:randre@gmail.com">randre@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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:<br><br>in_ds = gdal.Open('foo.png')<br>
band = dataset.GetRasterBand(1)<br>tile_data = band.ReadRaster( 0, 0, 50, 50, 2500, 1, GDT_Byte )<br><br>and then I would imagine I have to create the output dataset and write tile_data to it.<br></blockquote><div><br>Couldn't you just use<br>
<br>tile_data = band.ReadAsArray()[0:51, 0:51]<br><br>or even simpler (if it's an RGBA PNG)<br>g = gdal.Open("foo.png")<br>T = g.ReadAsArray () [:, 0:50, 0:50 ]<br>T.shape is now (4, 50, 50)<br><br>?<br><br>
J <br></div></div>