Using QwtRasterData for displaying the raster data resultant from R language
From here:http://cran.r-project.org/web/packages/ggmap/ggmap.pdf
Quote:
ggmap plots the raster object produced by get_map.
From: http://qwt.sourceforge.net/class_qwt_raster_data.html
Quote:
QwtRasterData defines an interface to any type of raster data
So, following way the data resultant from get_map is saved in a rda (raster) file.
Code:
mapImageData <- get_googlemap (c (lon=-74.0087986666667, lat=40.7106593333333), zoom=15)
save (mapImageData, file="savedMap.rda")
Will it be possible for me to display that resultant raster data on QwtRasterData class?
- What more information should I present here to know whether it can be done and how?
- Should I present a sample of raster data?
- Do I need to convert that raster data in a particular format before it can be loaded on the Qt widget?
Re: Using QwtRasterData for displaying the raster data resultant from R language
QwtRasterData assumes that you have a regular matrix of data values, one for every cell in the matrix. It then maps this (x,y,z) data to a spectrogram using bilinear interpolation to create colors for the pixels between raster points. QwtRasterData doesn't display anything; QwtPlotSpectrogram does that, using the data in QwtRasterData.
So, you need to parse the rda into a QwtRasterData structure, then decide on the color mapping to be used for displaying the spectrogram. Note that for the color mapping to work properly, you must set the z range such that min z and max z map to 0 and 1 on the color map, respectively.
I have no idea what an rda file looks like, so you will have to determine how to parse it.
And you probably want to use QwtMatrixRasterData; parse your rda file into a QVector< double > array of size (nRows * nCols), where each value in the vector is the value of z at that point. Use the "setValueMatrix()" and "setInterval()" methods to define the real-world x- and y-ranges of the data so the spectrogram can plot it properly.
Re: Using QwtRasterData for displaying the raster data resultant from R language
Quote:
QwtRasterData assumes that you have a regular matrix of data values, one for every cell in the matrix. It then maps this (x,y,z) data to a spectrogram using bilinear interpolation to create colors for the pixels between raster points.
This is what QwtMatrixRasterData does. QwtRasterData is simply an abstract API to bind the data ( however it looks like ) to a spectrogram.
Quote:
So, you need to parse the rda into a QwtRasterData structure, ...
All what needs to be done is to implement the abstract methods usually fetching the values from any applications specific data structures.
Quote:
And you probably want to use QwtMatrixRasterData; parse your rda file into a QVector< double > array of size (nRows * nCols) ...
When there is no other reason to have the values in memory this should be the easiest way to go.
Uwe