[Qgis-developer] Access raster data from python plugins

Tim Sutton tim at linfiniti.com
Tue Sep 9 16:07:42 EDT 2008

> Should really be something more like
> bool QgsRasterLayer::getValueAtCoordinates(const QgsPoint&, QMap<Qstirng,
> QString>&)
> bool QgsRasterLayer::getValueAtCoordinates(const QgsPoint&, int&)
> Which would open up other possibilities like (just to name a few),
> bool QgsRasterLayer::getValueAtCoordinates(const QList<QgsPoint>&,
> QMap<QgsPoint, int>&)
> bool QgsRasterLayer::getValueAtCoordinates(const QgsRect&, int, QMap<double,
> int>&)
> Get pixel frequencies in QgsRect for band X and return a list or map
> <pixelvalue, frequency>
> which would be great because it would also allow contrast enhancements to be
> defined based on the current data being displayed in the view port, but just
> all the data in the band.

We should probably also consider making these template functions so
that we can cater for the different gdal data types (float grids, int
grids etc) without implementing them multiple times for each type.

> So given the limited utility in the getValue function, I am hesitant to just
> drop it in, unless the other devs agree with move to getValueAtCoordinates()
> approach, then (as their current names are) getValue() can be added and
> identify() could simply call getValue() for each band. -- To make life
> easier identify() can can say in the API (marked as depreciated and slated
> for removal in 2.x ) and just be a wrapper for the getValueAtCoordinte().

I'm inclined to agree that it would be worth waiting for a subsequent
release so we can think it out properly rather than squeezing it into
this release (I'm about to send out a code freeze announcement tonight
anyway). Also it would be good to think about providing some basic
interpolator options so that we can e.g. get the mean of the local 3x3
window at the given point, or weight the return value if it is not at
the centroid of the cell based on neighbouring cell values.



Tim Sutton - QGIS Project Steering Committee Member (Release Manager)
Visit http://linfiniti.com to find out about:
 * QGIS programming services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux Irc: timlinux on #qgis at freenode.net

More information about the Qgis-developer mailing list