<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7651.59">
<TITLE>how to manipulate and save only one band</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">hi list,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">I appreciate if someone shows me</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">how to manipulate and save only one band</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New"> out of a multi-band raster.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">someone</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">wrote codes as follows</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New"> (results are band 1 is modified, the rest remain same)</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">vrtds=gdal.Open(vrtstr)</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New"> </FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">#</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">multi-band raste</FONT><FONT SIZE=2 FACE="Courier New">r</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">self.</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">new</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">_ds = gtiff_driver.CreateCopy( fname, vrtds, options = ['TILED=YES',],</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">..)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">bandobj = self.</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">new</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">_ds.GetRasterBand(</FONT><FONT SIZE=2 FACE="Courier New">1)</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> </SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">datablock = gdalnumeric.BandReadAsArray( bandobj</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">,</FONT> <FONT SIZE=2 FACE="Courier New">..</FONT><FONT SIZE=2 FACE="Courier New">)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"> </SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">…</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New"></FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">…</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"> </SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">gdalnumeric.BandWriteArray( bandobj, datablock, 0,</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">..</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">)</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">What I would like to do is: only keep</FONT> <FONT SIZE=2 FACE="Courier New">the</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">modified</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New"></FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">band</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">_</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">1</FONT> <FONT SIZE=2 FACE="Courier New">and delete rest bands from</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">“</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">self.</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">new</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">_d</FONT><FONT SIZE=2 FACE="Courier New">s</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">”</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">does gdal_dataset has a method called DeleteBand</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">()</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">?</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-us"></SPAN><A NAME=""><SPAN LANG="en-us"></SPAN><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">thanks,</FONT></SPAN></A></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">Shawn</FONT></SPAN></P>
<BR>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN></P>
</BODY>
</HTML>