From: Frank W. <war...@po...> - 2005-10-19 01:38:38
|
On 10/18/05, Luke Roth <luk...@ve...> wrote: > So far, my code looks like this, and it seems > to be working up until the point where I try to save the modified data > back to the image. Luke, I am reasonably sure your problem is that your modifications to "data_val" aren't really changing the array. The "for" loop is assign values from the array to your local variable. The reason we use "numpy" arrays is so that we can operate on the whole array in one python operation. Contrast what you do with the following code from gdal_merge.py for masking out nodata values. data_src =3D s_band.ReadAsArray( s_xoff, s_yoff, s_xsize, s_ysize, t_xsize, t_ysize ) data_dst =3D t_band.ReadAsArray( t_xoff, t_yoff, t_xsize, t_ysize ) nodata_test =3D Numeric.equal(data_src,nodata) to_write =3D Numeric.choose( nodata_test, (data_src, data_dst) ) t_band.WriteArray( to_write, t_xoff, t_yoff ) There is a certain zen to numpy logical opeations which I haven't completely absorted. But if you dig through the numpy manual you should be able to work out how to do it. You could do your manual iteration too of course, but I think you would need to manually iterate indices and use them to fetch values from the arrays, and then put the adjusted values back in the arrays. The other thing to keep in mind is to know whether OpenEV has opened the dataset in "update" mode or not. It does try for update mode, but if that fails it will settle for read-only mode. > Does anybody have any ideas what I am doing wrong, > or if there is a more correct / simpler way to do this? Also, what is > the appropriate way to contribute modified code back to the project? Patches to the application can be submitted via bugzilla. You can also maintain your own drop in "tools" yourself and/or submit them. What we really need is a set of contributed sample tools that wouldn't necessariliy appear in the menubar by default, but could be easily added and used as examples. Best regards, -- ---------------------------------------+-----------------------------------= --- I set the clouds in motion - turn up | Frank Warmerdam, warmerdam@pobox.c= om light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush | Geospatial Programmer for Rent |