Wednesday 9 September 2009

GdalRasterLayer and Ordnance Survey TIFF Files

..or any other raster files that use a colour palette.

So, having found out that you can use SharpMap's GdalRasterLayer to load and display
virtual datatsets, I quickly set about trying to get it working with the tiff files provided by Ordnance Survey.

However, when I actually tried to view the data I was presented with a big black nothing.


Turns out there is...not a bug exactly, but more of an 'omission' in the GdalRasterLayer code. At the time of writing both the 0.9 release and the current trunk build of SharpMap contain a version of GdalRasterLayer that cannot handle images that use colour palettes. And yes, all the raster data from Ordnance Survey (or at least, all the tiff files) make use of them.


I eventually came across a fix in this post. However, the patch was based on an old version of GdalRasterLayer and the code had moved on significantly. After a bit of head scratching I gave in and tried my hand at porting across the changes.

Now, the code is not beautiful. It doesn't seem to be a perfect fit. Having said that, I did not want to change the original code too drastically and so it is what it is...and it even seems to work!


Anyone who is interested can pick up it up from
here or download it from the original post here.

No comments:

Post a Comment