8

I want to get a pixel value fro the satellite image (Landat, GeoTIFF, 7 bands) using qgis-python.

What operators should i use? (for example in qgis's Python Console)

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Maaksaa
  • 81
  • 1
  • 2

2 Answers2

17

I do not know whether work for you or not , but you can check out gdallocationinfo. it is a raster query tool from gdal...

The gdallocationinfo utility provide a mechanism to query information about a pixel given it's location in one of a variety of coordinate systems. Several reporting options are provided.

$ gdallocationinfo utm.tif 256 256
Report:
  Location: (256P,256L)
  Band 1:
    Value: 115
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
urcm
  • 22,533
  • 4
  • 57
  • 109
2

There is another way:

LR = qgis.core.QgsRasterLayer("C:/Myfolder/test.tif", "test")
LR.width() #some properties
550
LR.height() #some properties
556
LR.extent().toString()
u'0.0000000000000000,-1001.0000000000000000 : 1001.0000000000000000,0.0000000000000000'
V = LR.dataProvider().identify(QgsPoint(100,-100), QgsRaster.IdentifyFormatValue)
V.results()
{1: 104.0, 2: 119.0, 3: 54.0}

this code show the value pixel for all 3 bands composit in image. Band 1 pixel value = 104; Band 2 pixel value = 119; Band 3 pixel value = 54;

PolyGeo
  • 65,136
  • 29
  • 109
  • 338