Re: [gdal-dev] Help with color map for raster grid

2014-02-25 Thread windchaser
Chaitanya,

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.

when trying to retrieve the color table using this statement ColorTable ct
= band.GetRasterColorTable(); the color table returned is empty.

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.

Are there any C# examples of using VRT dataset?
Could you highlight the main steps that I need to take in order to achieve
this?

Thanks,

public static Bitmap GetBitmap(string sFileName)
{
//**How to write manipulated raster values to ASCII grid with GDAL?
//**
http://stackoverflow.com/questions/10635107/how-to-write-manipulated-raster-values-to-ascii-grid-with-gdal
OSGeo.GDAL.Dataset ds = Gdal.Open(sFileName,
OSGeo.GDAL.Access.GA_ReadOnly);
if (ds == null)
{
MessageBox.Show(Invalid File Format!);
return null;
}

OSGeo.GDAL.Driver dr = ds.GetDriver();

int nWidth = ds.RasterXSize;
int nHeight = ds.RasterYSize;

//** GDAL CSharp Guide gdal - Revision 26980:
/trunk/gdal/swig/csharp/apps
//** http://svn.osgeo.org/gdal/trunk/gdal/swig/csharp/apps/

// Creating a Bitmap to store the GDAL image in
Bitmap bitmap = new Bitmap(nWidth, nHeight,
PixelFormat.Format8bppIndexed);
// Obtaining the bitmap buffer
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, nWidth,
nHeight), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
try
{
int stride = bitmapData.Stride;
IntPtr buf = bitmapData.Scan0;
Band band = ds.GetRasterBand(1);
band.ReadRaster(0, 0, nWidth, nHeight, buf, nWidth, nHeight,
DataType.GDT_Byte, 1, stride);
}
finally
{
bitmap.UnlockBits(bitmapData);
}

return bitmap;
}



*Daniel*
c: 1 (705) 499-2450


On Tue, Feb 25, 2014 at 12:01 AM, chaitanya_ch [via OSGeo.org] 
ml-node+s1560n510570...@n6.nabble.com wrote:

 Daniel,

 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.

 http://www.gdal.org/gdalbuildvrt.html
 http://www.gdal.org/gdal_vrttut.html

 --
 Best regards,
 Chaitanya Kumar CH
 On 25-Feb-2014 9:26 am, windchaser [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5105703i=0
 wrote:

 Hi,
 I am working with GDAL in a C# project. I need help figuring out how to
 increase the colors displayed on a raster grid. Opening the file using
 Gdal.Open(myfile, OSGeo.GDAL.Access.GA_ReadOnly); seems to offer some
 colors but I would like to increase the number of colors for the raster
 map,
 specially for floating point raster.

 Here is an example of what i am trying to achieve using GDAL.

 http://screencast.com/t/LPjJ7pTk http://screencast.com/t/LPjJ7pTk

 Thanks for your help!

 Daniel



 --
 View this message in context:
 http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698.html
 Sent from the GDAL - Dev mailing list archive at Nabble.com.
 ___
 gdal-dev mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=5105703i=1
 http://lists.osgeo.org/mailman/listinfo/gdal-dev


 ___
 gdal-dev mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=5105703i=2
 http://lists.osgeo.org/mailman/listinfo/gdal-dev

 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698p5105703.html
  To unsubscribe from Help with color map for raster grid, click 
 herehttp://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=5105698code=ZGthbWluc2tpQGdtYWlsLmNvbXw1MTA1Njk4fDYwNTc3NjY1OA==
 .
 NAMLhttp://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698p5105844.html
Sent from the GDAL - Dev mailing list 

Re: [gdal-dev] Help with color map for raster grid

2014-02-25 Thread Chaitanya kumar CH
Daniel,

You can build your own colour table using the api. In not familiar with the
C# interface but for C, you can refer to
http://gdal.org/classGDALColorTable.html

--
Best regards,
Chaitanya Kumar CH
On 25-Feb-2014 8:58 pm, windchaser dkamin...@gmail.com wrote:

 Chaitanya,

 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.

 when trying to retrieve the color table using this statement ColorTable
 ct = band.GetRasterColorTable(); the color table returned is empty.

 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.

 Are there any C# examples of using VRT dataset?
 Could you highlight the main steps that I need to take in order to achieve
 this?

 Thanks,

 public static Bitmap GetBitmap(string sFileName)
 {
 //**How to write manipulated raster values to ASCII grid with GDAL?
 //**
 http://stackoverflow.com/questions/10635107/how-to-write-manipulated-raster-values-to-ascii-grid-with-gdal
 OSGeo.GDAL.Dataset ds = Gdal.Open(sFileName,
 OSGeo.GDAL.Access.GA_ReadOnly);
 if (ds == null)
 {
 MessageBox.Show(Invalid File Format!);
 return null;
 }

 OSGeo.GDAL.Driver dr = ds.GetDriver();

 int nWidth = ds.RasterXSize;
 int nHeight = ds.RasterYSize;

 //** GDAL CSharp Guide gdal - Revision 26980:
 /trunk/gdal/swig/csharp/apps
 //** http://svn.osgeo.org/gdal/trunk/gdal/swig/csharp/apps/

 // Creating a Bitmap to store the GDAL image in
 Bitmap bitmap = new Bitmap(nWidth, nHeight,
 PixelFormat.Format8bppIndexed);
 // Obtaining the bitmap buffer
 BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0,
 nWidth, nHeight), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
 try
 {
 int stride = bitmapData.Stride;
 IntPtr buf = bitmapData.Scan0;
 Band band = ds.GetRasterBand(1);
 band.ReadRaster(0, 0, nWidth, nHeight, buf, nWidth, nHeight,
 DataType.GDT_Byte, 1, stride);
 }
 finally
 {
 bitmap.UnlockBits(bitmapData);
 }

 return bitmap;
 }



 *Daniel*
 c: 1 (705) 499-2450


 On Tue, Feb 25, 2014 at 12:01 AM, chaitanya_ch [via OSGeo.org] [hidden
 email] http://user/SendEmail.jtp?type=nodenode=5105844i=0 wrote:

 Daniel,

 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.

 http://www.gdal.org/gdalbuildvrt.html
 http://www.gdal.org/gdal_vrttut.html

 --
 Best regards,
 Chaitanya Kumar CH
 On 25-Feb-2014 9:26 am, windchaser [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5105703i=0
 wrote:

 Hi,
 I am working with GDAL in a C# project. I need help figuring out how to
 increase the colors displayed on a raster grid. Opening the file using
 Gdal.Open(myfile, OSGeo.GDAL.Access.GA_ReadOnly); seems to offer some
 colors but I would like to increase the number of colors for the raster
 map,
 specially for floating point raster.

 Here is an example of what i am trying to achieve using GDAL.

 http://screencast.com/t/LPjJ7pTk http://screencast.com/t/LPjJ7pTk

 Thanks for your help!

 Daniel



 --
 View this message in context:
 http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698.html
 Sent from the GDAL - Dev mailing list archive at Nabble.com.
 ___
 gdal-dev mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=5105703i=1
 http://lists.osgeo.org/mailman/listinfo/gdal-dev


 ___
 gdal-dev mailing list
 [hidden email] http://user/SendEmail.jtp?type=nodenode=5105703i=2
 http://lists.osgeo.org/mailman/listinfo/gdal-dev

 --
  If you reply to this email, your message will be added to the
 discussion below:

 http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698p5105703.html
  To unsubscribe from Help with color map for raster grid, click here.
 

[gdal-dev] Help with color map for raster grid

2014-02-24 Thread windchaser
Hi,
I am working with GDAL in a C# project. I need help figuring out how to
increase the colors displayed on a raster grid. Opening the file using
Gdal.Open(myfile, OSGeo.GDAL.Access.GA_ReadOnly); seems to offer some
colors but I would like to increase the number of colors for the raster map,
specially for floating point raster.

Here is an example of what i am trying to achieve using GDAL.

http://screencast.com/t/LPjJ7pTk http://screencast.com/t/LPjJ7pTk  

Thanks for your help!

Daniel



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Help with color map for raster grid

2014-02-24 Thread Chaitanya kumar CH
Daniel,

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.

http://www.gdal.org/gdalbuildvrt.html
http://www.gdal.org/gdal_vrttut.html

--
Best regards,
Chaitanya Kumar CH
On 25-Feb-2014 9:26 am, windchaser dkamin...@gmail.com wrote:

 Hi,
 I am working with GDAL in a C# project. I need help figuring out how to
 increase the colors displayed on a raster grid. Opening the file using
 Gdal.Open(myfile, OSGeo.GDAL.Access.GA_ReadOnly); seems to offer some
 colors but I would like to increase the number of colors for the raster
 map,
 specially for floating point raster.

 Here is an example of what i am trying to achieve using GDAL.

 http://screencast.com/t/LPjJ7pTk http://screencast.com/t/LPjJ7pTk

 Thanks for your help!

 Daniel



 --
 View this message in context:
 http://osgeo-org.1560.x6.nabble.com/Help-with-color-map-for-raster-grid-tp5105698.html
 Sent from the GDAL - Dev mailing list archive at Nabble.com.
 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev