PDA

View Full Version : Plot Raster chart background



jmsbc
5th August 2010, 22:59
Hello,

I am trying to load NOAA raster charts into the background of QwtPlot. I used GDAL to read the charts to create a geotiff file, so let's say I have a geotiff chart with dimensions roughly 12,000 by 8,000.

I was thinking about using GDAL_translate to crop according to geospatial coordinates (-projwin option) and to resample according to number of pixels and lines (-outsize option) to create an image (bitmap). This is done whenever the user pans or zooms the plot, and then I would load the generated image (bitmap) in my QwtPlotItem to draw the background.

However, then I saw the QwtRasterItem class and thought that I would be able to load the whole 12,000 by 8,000 geotiff (converted to bitmap) into a rasterData and let the rasterItem automatically re-sample and draw the background.

Is this approach possible? And has anyone else ever had experience loading a huge background image and then resampling for the zoom/pan?

Thank you

Uwe
6th August 2010, 00:11
I have written such a raster item for geotiff maps a couple of years ago. As far as I remember we had divided our maps into tiles ( our maps were much more, than 12000x8000, but a tile was smaller ) and the most difficult thing was to put these tiles together for each image composition.

AFAIR I had a TIFF library that offered to read the file line by line, so I didn't need to have all in memory at once. If your plot and your tiff files use the same projection all you need to do is to run over the lines in your image translate each pixel into your coordinates and pick the closest pixel from your tiff image.

Unfortunately a lot of code that does the interaction between raster data and raster item can be found in the implementation of QwtPlotSpectrogram::renderImage instead of its base class ( where it should be ). So I'm afraif you have to copy some code, that calculates the size ( = resolution ) of the image and its position in scale coordinates.

Uwe

jmsbc
6th August 2010, 22:44
Yeah, there seem to be many different approaches to this problem, so I was trying to attack it using the simplest method I knew how first. In the end it would probably be a good idea for me to create tiles to be loaded from a database as well.

Would that code that you wrote for geotiff maps happen to be publicly available? :D

Thanks

Uwe
8th August 2010, 19:56
No, I'm not the owner of this code.

Uwe