[Gdal-dev] gdal_merge.py in c#
Frank Warmerdam
warmerdam at pobox.com
Tue Aug 7 11:33:35 EDT 2007
Suray Ph wrote:
> Hello,
>
> I try to convert some commandline utilities, written in python, in c#.
>
> I need help for gdal_merge.py. I found in this file a 'function' called
> 'raster_copy_with_nodata', could some one explain me how to convert this one,
> especialy band.ReadAsArray(...), Numeric.equal(...), Numeric.choose(...),
> band.WriteArray(...).
>
> I searched for documentation about python, but didn't find the right one.
>
> The final goal is to be able to merge different reprojected GTiff files, with
> black area, into one without black area.
Philippe,
These are Numeric Python methods and as such there is unlikely to be a
direct C# analog. But if you can read back the image as an array in
C# you can just loop over the array, doing comparisons to the nodata
value, and overlaying where appropriate.
Basically, this script code:
data_src = s_band.ReadAsArray( s_xoff, s_yoff, s_xsize, s_ysize,
t_xsize, t_ysize )
data_dst = t_band.ReadAsArray( t_xoff, t_yoff, t_xsize, t_ysize )
nodata_test = Numeric.equal(data_src,nodata)
to_write = Numeric.choose( nodata_test, (data_src, data_dst) )
t_band.WriteArray( to_write, t_xoff, t_yoff )
means:
1) read the source and destination image data.
2) Where source image pixel is *not* equal to the nodata value, copy
it into the destination image.
3) write the destination image back.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the Gdal-dev
mailing list