Thanks for the suggestion.<br><br>I have tried:<br><br><div style="margin-left: 40px;">tileRaster = self.raster.ReadAsArray(xoff=offsetX, yoff=offsetY, win_xsize=width, win_ysize=height)<br></div> <br>and<br><br><div style="margin-left: 40px;">
tileRaster = self.raster.ReadAsArray(xoff=offsetX, yoff=offsetY, buf_xsize=width, buf_ysize=height)<br></div> <br>but the result is something like:<br><br><div style="margin-left: 40px;">(array([], shape=(0, 1024), dtype=float32), 0, 0, 1024, 0)<br>
</div><br><br>Riaan<br><br><div class="gmail_quote">On Fri, Sep 3, 2010 at 1:33 PM, Chaitanya kumar CH <span dir="ltr"><<a href="http://chaitanya.ch">chaitanya.ch</a>@<a href="http://gmail.com">gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Riaan,<br><br>Try calling the method as below<br>tileRaster = self.raster.ReadAsArray(xoff=offsetX, yoff=offsetY, xsize=width, ysize=height)<br>
<br><div class="gmail_quote"><div><div></div><div class="h5">On Fri, Sep 3, 2010 at 4:09 PM, Riaan van den Dool <span dir="ltr"><<a href="mailto:riaanvddool@gmail.com" target="_blank">riaanvddool@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">I have recently started a new open-source project that will use gdal extensively, named scikits.eartho.<br>
<br>The vision is to implement some advanced algorithms and ideas that we develop and work with at the South African Satellite Applications Centre (SAC) for use in Python (SciPy).<br>
<br>I am experiencing some trouble with RasterBand.ReadAsArray.<br><br>My python code:<br><br><div style="margin-left: 40px;">import osgeo.gdal as gdal<br><br>class RasterReaderWriter:<br> def __init__(self, raster):<br>
self.raster = raster<br> self.tileWidth =1024<br> self.tileHeight = 1024<br> self.tileNum = 0 <br> <br> def setTileSize(self, width, height):<br> self.tileWidth =width<br> self.tileHeight = height<br>
<br> def resetIterator(self):<br> self.tileNum = 0<br> <br> def readNextTile(self):<br> tileRaster, offsetX, offsetY, width, height = self.readTile(self.tileNum)<br> self.tileNum = self.tileNum + 1<br>
return tileRaster, offsetX, offsetY, width, height <br> <br> def readTile(self, tileNum):<br> tilesInWidth = self.raster.XSize / self.tileWidth + 1<br> offsetX = tileNum % tilesInWidth * self.tileWidth<br>
offsetY = tileNum / tilesInWidth * self.tileHeight<br> width = min(self.tileWidth, self.raster.XSize - offsetX) <br> height = min(self.tileHeight, self.raster.YSize - offsetY) <br> print offsetX, offsetY, width, height<br>
tileRaster = self.raster.ReadAsArray(offsetX, offsetY, width, height)<br> return tileRaster, offsetX, offsetY, width, height <br><br><br><br><br>reader = RasterReaderWriter(gdal.Open(iFilename).GetRasterBand(1))<br>
print reader.raster.XSize<br>print reader.raster.YSize<br>tile, offsetX, offsetY, width, height = reader.readNextTile()<br></div><br>Before the call to readNextTile() the raster XSize and YSize is correct.<br>After the call the raster seems to have been corrupted as the XSize and YSize have invalid values.<br>
<br>Any help would be appreciated!<br><font color="#888888"><br>Riaan<br>
</font><br></div></div>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>Best regards,<br>
Chaitanya kumar CH.<br>
/tʃaɪθənjə/ /kʊmɑr/ <br>+91-9494447584<br>17.2416N 80.1426E<br>
</font></blockquote></div><br>