<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Chaitanya,</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">
Thanks for your prompt reply. I think I would like to use display engine, but I am still trying to figure out which function I need to use to 'load a different color table'. I am using GDAL with C# in a VS2010 project. Below is the function that opens the raster text file and returns the bitmap. </div>
<div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">when trying to retrieve the color table using this statement "ColorTable ct = band.GetRasterColorTable();" the color table returned is empty.</div>
<div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">>From your post I understand that a VRT dataset needs to be created by copying the source dataset and then this VRT dataset can be manipulated to add more classes apply a color gradient to the classes.<br>
</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Are there any C# examples of using VRT dataset? </div><div class="gmail_default" style="font-family:verdana,sans-serif">
Could you highlight the main steps that I need to take in order to achieve this?</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">
Thanks,</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default"><div class="gmail_default"><font face="verdana, sans-serif"> public static Bitmap GetBitmap(string sFileName)</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> {</font></div><div class="gmail_default"><font face="verdana, sans-serif"> //**How to write manipulated raster values to ASCII grid with GDAL?</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> //**<a href="http://stackoverflow.com/questions/10635107/how-to-write-manipulated-raster-values-to-ascii-grid-with-gdal" target="_top" rel="nofollow" link="external">http://stackoverflow.com/questions/10635107/how-to-write-manipulated-raster-values-to-ascii-grid-with-gdal</a></font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> OSGeo.GDAL.Dataset ds = Gdal.Open(sFileName, OSGeo.GDAL.Access.GA_ReadOnly);</font></div><div class="gmail_default"><font face="verdana, sans-serif"> if (ds == null)</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> {</font></div><div class="gmail_default"><font face="verdana, sans-serif"> MessageBox.Show("Invalid File Format!");</font></div><div class="gmail_default">
<font face="verdana, sans-serif"> return null;</font></div><div class="gmail_default"><font face="verdana, sans-serif"> }</font></div><div class="gmail_default"><font face="verdana, sans-serif"><br></font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> OSGeo.GDAL.Driver dr = ds.GetDriver();</font></div><div class="gmail_default"><font face="verdana, sans-serif"><br></font></div><div class="gmail_default">
<font face="verdana, sans-serif"> int nWidth = ds.RasterXSize;</font></div><div class="gmail_default"><font face="verdana, sans-serif"> int nHeight = ds.RasterYSize;</font></div><div class="gmail_default"><font face="verdana, sans-serif"><br>
</font></div><div class="gmail_default"><font face="verdana, sans-serif"> //** GDAL CSharp Guide gdal - Revision 26980: /trunk/gdal/swig/csharp/apps</font></div><div class="gmail_default"><font face="verdana, sans-serif"> //** <a href="http://svn.osgeo.org/gdal/trunk/gdal/swig/csharp/apps/" target="_top" rel="nofollow" link="external">http://svn.osgeo.org/gdal/trunk/gdal/swig/csharp/apps/</a></font></div>
<div class="gmail_default"><font face="verdana, sans-serif"><br></font></div><div class="gmail_default"><font face="verdana, sans-serif"> // Creating a Bitmap to store the GDAL image in</font></div><div class="gmail_default">
<font face="verdana, sans-serif"> Bitmap bitmap = new Bitmap(nWidth, nHeight, PixelFormat.Format8bppIndexed); </font></div><div class="gmail_default"><font face="verdana, sans-serif"> // Obtaining the bitmap buffer</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, nWidth, nHeight), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); </font></div><div class="gmail_default">
<font face="verdana, sans-serif"> try</font></div><div class="gmail_default"><font face="verdana, sans-serif"> {</font></div><div class="gmail_default"><font face="verdana, sans-serif"> int stride = bitmapData.Stride;</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> IntPtr buf = bitmapData.Scan0;</font></div><div class="gmail_default"><font face="verdana, sans-serif"> Band band = ds.GetRasterBand(1);</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> band.ReadRaster(0, 0, nWidth, nHeight, buf, nWidth, nHeight, DataType.GDT_Byte, 1, stride);</font></div><div class="gmail_default"><font face="verdana, sans-serif"> }</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> finally</font></div><div class="gmail_default"><font face="verdana, sans-serif"> {</font></div><div class="gmail_default"><font face="verdana, sans-serif"> bitmap.UnlockBits(bitmapData);</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> }</font></div><div class="gmail_default"><font face="verdana, sans-serif"><br></font></div><div class="gmail_default"><font face="verdana, sans-serif"> return bitmap;</font></div>
<div class="gmail_default"><font face="verdana, sans-serif"> }</font></div><div style="font-family:verdana,sans-serif"><br></div></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div></div>
<div class="gmail_extra">
<br clear="all"><div><b><font face="verdana, sans-serif">Daniel</font></b><div><font face="verdana, sans-serif">c: 1 (705) 499-2450</font></div></div>
<br><br><div class="gmail_quote">On Tue, Feb 25, 2014 at 12:01 AM, chaitanya_ch [via OSGeo.org] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=5105844&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>></span> wrote:<br>
<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
<p dir="ltr">Daniel,</p>
<p dir="ltr">You can make changes in two places. In the data or the display engine. In the data, you can modify the colour table. This will be permanent. In the display, you just load a different color table based on the table of pixel values. If you don't like either, you can build a gdal vrt file and modify its colour table.</p>
<p dir="ltr"><a href="http://www.gdal.org/gdalbuildvrt.html" rel="nofollow" link="external" target="_blank">http://www.gdal.org/gdalbuildvrt.html</a><br>
<a href="http://www.gdal.org/gdal_vrttut.html" rel="nofollow" link="external" target="_blank">http://www.gdal.org/gdal_vrttut.html</a></p>
<p dir="ltr">--<br>
Best regards,<br>
Chaitanya Kumar CH</p>
</div><div class="gmail_quote"><div><div class="h5">On 25-Feb-2014 9:26 am, "windchaser" <<a href="http://user/SendEmail.jtp?type=node&node=5105703&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>> wrote:<br type="attribution">
</div></div><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #cccccc;padding:0 1em" class="gmail_quote"><div><div class="h5">
Hi,<br>
I am working with GDAL in a C# project. I need help figuring out how to<br>
increase the colors displayed on a raster grid. Opening the file using<br>
Gdal.Open("myfile", OSGeo.GDAL.Access.GA_ReadOnly); seems to offer some<br>
colors but I would like to increase the number of colors for the raster map,<br>
specially for floating point raster.<br>
<br>
Here is an example of what i am trying to achieve using GDAL.<br>
<br>
<a href="http://screencast.com/t/LPjJ7pTk" rel="nofollow" link="external" target="_blank">http://screencast.com/t/LPjJ7pTk</a> <<a href="http://screencast.com/t/LPjJ7pTk" rel="nofollow" link="external" target="_blank">http://screencast.com/t/LPjJ7pTk</a>><br>
<br>
Thanks for your help!<br>
<br>
Daniel<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698.html" rel="nofollow" link="external" target="_blank">http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698.html</a><br>
Sent from the GDAL - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
</div></div><a href="http://user/SendEmail.jtp?type=node&node=5105703&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>
<br>_______________________________________________
<br>gdal-dev mailing list
<br><a href="http://user/SendEmail.jtp?type=node&node=5105703&i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
<br>
<br>
<hr noshade size="1" color="#cccccc">
<div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
<div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
<a href="http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698p5105703.html" target="_blank" rel="nofollow" link="external">http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698p5105703.html</a>
</div>
<div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
To unsubscribe from Help with color map for raster grid, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>
<a href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
</div></blockquote></div><br></div>
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698p5105844.html">Re: Help with color map for raster grid</a><br/>
Sent from the <a href="http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html">GDAL - Dev mailing list archive</a> at Nabble.com.<br/>