[FWTools] WriteRaster outputs incorrect values
ecollage at gmail.com
Tue Mar 28 11:08:32 EST 2006
I've been working on a tool that helps correct contiguous patches of
mis-classified imagery with an interactive 'change-value-to:__' using a
flood-fill routine and it works - well somewhat :(
The line i'm using to write the new value:
gives me a raster with values written as 91 no matter what value one
actually wants to write . what am i doing wrong?
the code i've written is provided below (lifted from a routine by Eric
Raymond at http://aspn.activestate.com/ASPN/Mail/Message/image-sig/2825804).
it uses a copy (saved as ...demo-data/newfile.tif) to avoid mucking up the
if you can help...
def floodlist(self, pixel=None,line=None,value=None,newvalue=None):
edge = 
base_ds = self.app.view_manager.get_active_view
bbase = vrtutils.serializeDataset(base_ds.get_dataset())
vrtlines = gdal.SerializeXMLTree(bbase)
vrtds = gdal.OpenShared(vrtlines)
driver = gdal.GetDriverByName('GTiff')
fname = os.path.join(gview.home_dir,'demo-data','newtest.tif')
vrtds2 = driver.CreateCopy(fname,vrtds)
newedge = 
for (pixel,line) in edge:
for (s,t) in ((pixel+1, line), (pixel-1, line), (pixel,
line+1), (pixel, line-1)):
newvalue = vrtds2.GetRasterBand(1).ReadAsArray(s,t,1,1)
if newvalue == value:
edge = newedge
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the FWTools