comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Get pixel info from an geotiff ROI (lat long)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Get pixel info from an geotiff ROI (lat long) [message #57590] Sun, 16 December 2007 17:36
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
aleks.franca@gmail.com writes:

> Thank you David. Your hint was of good help, but I still have some
> problems. I'm using POLLYFILLV because I still have problems with
> objects, but I'll get over it soon.
>
> The input is a txt file with the coordinates of a Region in lat long.
> I take that and interpret each coordinate in a pixel value:
>
> vetGridX = intarr(n_elements(vetLonX))
> vetGridY = intarr(n_elements(vetLatY))
>
> for i=0, n_elements(vetGridX)-1 do $
> begin
> vetGridX[i] = fix((vetLonX[i] - LongMin) / pixelSize_X)
> vetGridY[i] = fix((vetLatY[i] - LatMin) / pixelSize_Y)
> endfor
> vetGridY = (2791-vetGridY) ;2791 is the ysize of the image
>
> ;I have then 2 vectors if integer
> VETGRIDX INT = Array[554]
> VETGRIDY INT = Array[554]
>
> ;After that I make them become vectors of a single string.
> vetGridX = strtrim(vetGridX, 2)
> vetGridY = strtrim(vetGridY, 2)
>
> vetGridX = STRJOIN(vetGridX, ',')
> vetGridY = STRJOIN(vetGridY, ',')
>
> ;This is an example of the first and last points of the string.
> ;Note that some points are repeated.
> VETGRIDX STRING = 769,769,770,770,770 ...
> 771,771,770,770,770,770,770,770,770,770
> VETGRIDY STRING = 1100,1100,1100,1100,1100 ...
> 1101,1101,1101,1101,1101,1101,1101,1100,1100,1100
>
> ;I use the function like this:
> P = img[polyfillv([VETGRIDX], [VETGRIDY], 4453, 2791)]
>
> And this is the result
> % POLYFILLV: Not enough valid and unique points specified.
>
>
> I've thougth that the first and the last point cannot repeat, so I've
> tried that and the function works just once and never happened again.
> That's very crazy.
>
> Would someone help me on that?

Humm, I'm going to a concert tonight. But have you tried NOT
treating them as strings. (I've never heard of this, honestly.)
Try just passing the integers. I've no idea why POLYFILLV
is complaining, but it is possible he is as confused about
your method as I am. If you have too many of the same points,
you might have to decimate your polygon. See my article on
MESH_DECIMATE for some suggestions. Then I would have a look
at your polygons to see if they still look right.

Wife's calling, have to go...

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Get pixel info from an geotiff ROI (lat long) [message #57591 is a reply to message #57590] Sun, 16 December 2007 17:10 Go to previous message
aleks.franca@gmail.co is currently offline  aleks.franca@gmail.co
Messages: 33
Registered: March 2007
Member
> POLYFILLV will return all the pixel indices inside your
> polygon. But I would really think about putting these
> ROIs into IDLanROI objects. That way you get methods that
> do just about everything you can think of to do with an
> ROI.
>
> Cheers,
>
> David

Thank you David. Your hint was of good help, but I still have some
problems. I'm using POLLYFILLV because I still have problems with
objects, but I'll get over it soon.

The input is a txt file with the coordinates of a Region in lat long.
I take that and interpret each coordinate in a pixel value:

vetGridX = intarr(n_elements(vetLonX))
vetGridY = intarr(n_elements(vetLatY))

for i=0, n_elements(vetGridX)-1 do $
begin
vetGridX[i] = fix((vetLonX[i] - LongMin) / pixelSize_X)
vetGridY[i] = fix((vetLatY[i] - LatMin) / pixelSize_Y)
endfor
vetGridY = (2791-vetGridY) ;2791 is the ysize of the image

;I have then 2 vectors if integer
VETGRIDX INT = Array[554]
VETGRIDY INT = Array[554]

;After that I make them become vectors of a single string.
vetGridX = strtrim(vetGridX, 2)
vetGridY = strtrim(vetGridY, 2)

vetGridX = STRJOIN(vetGridX, ',')
vetGridY = STRJOIN(vetGridY, ',')

;This is an example of the first and last points of the string.
;Note that some points are repeated.
VETGRIDX STRING = 769,769,770,770,770 ...
771,771,770,770,770,770,770,770,770,770
VETGRIDY STRING = 1100,1100,1100,1100,1100 ...
1101,1101,1101,1101,1101,1101,1101,1100,1100,1100

;I use the function like this:
P = img[polyfillv([VETGRIDX], [VETGRIDY], 4453, 2791)]

And this is the result
% POLYFILLV: Not enough valid and unique points specified.


I've thougth that the first and the last point cannot repeat, so I've
tried that and the function works just once and never happened again.
That's very crazy.

Would someone help me on that?

Thank you!

Aleksander
Re: Get pixel info from an geotiff ROI (lat long) [message #57599 is a reply to message #57591] Sun, 16 December 2007 06:19 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
aleks.franca@gmail.com writes:

> I have a problem with georreferenced tiff files. I need to get pixel
> information from a geotiff image. I have the coordinates LAT LONG of a
> ROI. Inside the Region of interest I need to get information about the
> pixels, such as the many of pixels, and their values.
> It seems to be very simple, but I can't find the right function. I've
> tried to use CONTOUR, but it doesn't give pixel values. I've also
> tried POLYFILL, but it just draws the polygons.
> Could somebody please advise me with a function in IDL, so I could
> work on?

POLYFILLV will return all the pixel indices inside your
polygon. But I would really think about putting these
ROIs into IDLanROI objects. That way you get methods that
do just about everything you can think of to do with an
ROI.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Get pixel info from an geotiff ROI (lat long)
Next Topic: Matrix rank

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:04:14 PDT 2025

Total time taken to generate the page: 0.00460 seconds