<!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.7226.0">
<TITLE>gdaldataset writeraster</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">H</FONT><FONT SIZE=2 FACE="Courier New">i</FONT> <FONT SIZE=2 FACE="Courier New">list,</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"><FONT SIZE=2 FACE="Courier New">I</FONT> <FONT SIZE=2 FACE="Courier New">open a</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">gdaldataset</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">, have done manipulation to r,g,b and nir bands.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">Now I</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">d like to save the 4 bands bac</FONT><FONT SIZE=2 FACE="Courier New">k</FONT><FONT SIZE=2 FACE="Courier New"> to</FONT> <FONT SIZE=2 FACE="Courier New">original</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">gdaldataset</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New"> or a new dataset.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">Can</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">t seem to get</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">gdaldataset</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">s WriteRaster() working, or is it the right method?</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">P</FONT><FONT SIZE=2 FACE="Courier New">lease</FONT> <FONT SIZE=2 FACE="Courier New">help.</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"> fname1 =</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">file3.tif'</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New"> msi_dataset = gdal.Open(fname1)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New"> </FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">msi_array = msi_dataset.ReadAsArray()</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> </FONT> <FONT SIZE=2 FACE="Courier New">r = msi_array[:][:][0]</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> g = msi_array[:][:][1]</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> </FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"> <FONT SIZE=2 FACE="Courier New">b = msi_array[:][:][2]</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="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> </FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">nir =</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">msi_array[:][:][</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">3</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">]</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> row = msi_dataset.RasterYSize</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> col = msi_dataset.RasterXSize</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"><FONT SIZE=2 FACE="Courier New">the following I am not sure:</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="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> </FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">msi</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">_dataset.WriteRaster(0, 0, col, row, r, col, row, Numeric.Float16, [</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">0</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">])</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> </FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">msi</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">_dataset.WriteRaster(0, 0, col, row,</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">g</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">, col, row, Numeric.Float16, [</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">1</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">]</FONT><FONT SIZE=2 FACE="Courier New">)</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> </FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">msi</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">_dataset.WriteRaster(0, 0, col, row,</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">b</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">, col, row, Numeric.Float1</FONT><FONT SIZE=2 FACE="Courier New">6</FONT><FONT SIZE=2 FACE="Courier New">, [</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">2</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">]</FONT><FONT SIZE=2 FACE="Courier New">)</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New"> </FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">msi</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">_dataset.WriteRaster(0, 0, col, row,</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"> <FONT SIZE=2 FACE="Courier New">nir</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">, col, row, Numeric.Float1</FONT><FONT SIZE=2 FACE="Courier New">6</FONT><FONT SIZE=2 FACE="Courier New">, [</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">3</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">]</FONT><FONT SIZE=2 FACE="Courier New">)</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN></P>
<P DIR=LTR><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">Thanks,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="it"><FONT SIZE=2 FACE="Courier New">Shawn Gong</FONT></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-ca"></SPAN><SPAN LANG="en-ca"></SPAN><SPAN LANG="it"></SPAN></P>
</BODY>
</HTML>