Clear Filters
Clear Filters

How to read arbitrary pixel values from a geotiff image?

1 view (last 30 days)
Hi
I'm looking for a function to read values from a geotiff image for an array of arbitrary lat,lon coordinates.
Something like this:
val = pixtiffread(filename,lat,lon,refmat)
imread for tiff images lets you specify a pixelreagion but I can't find a function that takes lat and lon vectors.
Any help would be appreciated. Regards Neil

Accepted Answer

Image Analyst
Image Analyst on 6 May 2012
The help for imread says: "'PixelRegion': Cell array, {Rows, Cols}, specifying the boundaries of the region. Rows and Cols must be either two- or three-element vectors. If you specify two elements, the values denote the 1-based indices [start stop]. If you specify three elements, the values denote the 1-based indices [start increment stop], to allow image downsampling."
So why can't you use that? Just have x by the columns, and y be the rows? Or else why can't you just read in the whole image and extract the values like pixelValue = yourImage(y, x), where you do that for each x and y that you have?
  3 Comments
Image Analyst
Image Analyst on 7 May 2012
How big is your image? Can you sort your x and y points into where they would lie if you divided your image up into, say, 10 by 10 blocks? Then you can read in one block at a time, read pixel values for the coordinates that lie in that block, and do this for every block of the image.
Neil Caithness
Neil Caithness on 23 Aug 2012
Thanks, I will probably have to do it that way but I'm still hoping that someone might suggest an efficient solution for reading pixel values directly from geotiff files for arbitrary vectors of x,y coordinates.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!