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

Home » Public Forums » archive » Problem with ENVI_CONVERT_File_COORDINATES
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
Problem with ENVI_CONVERT_File_COORDINATES [message #58833] Sun, 24 February 2008 08:14 Go to next message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
Hi,
I am having trouble to retrive a pixel value by geographic long lats.
Following is the code. two values obtained by sample/line coordinate
and geographic long lats are different. What is wrong with my code?
Thanks

;======================================================
;Open a file using envi batch

envi_open_file, fNameInput, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Open the file to read in array
OpenR, Lun, fNameInput,/Get_Lun

; Setup the values for the keywords

envi_file_query, fid, ns=ns, nl=nl, nb=nb, data_type=data_type,$
interleave=interleave, dims=dims

Image=Make_Array(ns,nl,nb); create an array to get the values of the
image
readu, lun, Image; read the image pixel values into the array
Free_Lun, Lun

;print a pixel value by sample and rows
print, image[1040, 404, *] ;this prints pixel values for 6 bands
; this fine, correct

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Retrieve a pixel value by geographic long lats
;get coordinates for image and convert to lat/lon
xcoord=116.521
ycoord= 40.1455

;change from lat/long coordinates to pixel values

ENVI_CONVERT_File_COORDINATES, fid, xF, yF,xcoord, ycoord
for nb=0, nb-1 do begin ;read multi band data
data = ENVI_GET_DATA(fid=fid, dims=dims, pos=nb); pos is the
name of the band, 0=1st band, 5=6th band
output=data[xcoord, ycoord,*]
print, output; this prints pixel values for 6 bands
endfor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;
Re: Problem with ENVI_CONVERT_File_COORDINATES [message #58889 is a reply to message #58833] Tue, 26 February 2008 08:37 Go to previous messageGo to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
bulrushmower@gmail.com wrote:
> I tried these methods, however, did not work. Thanks anyway.


can you print xF, yF and the original coords?
Could it be a rounding problem? ... you assume to read one pixel but
because of rounding it reads the previous pixel value?

Jean


> On Feb 25, 10:10 am, Pete <peter.e...@shaw.ca> wrote:
>> I would check the usage of:
>>
>>> ENVI_CONVERT_File_COORDINATES, fid, xF, yF,xcoord, ycoord
>> If I understand correctly, you are trying to get the xF and yF values
>> from the hard coded Xmap and Ymap coordinates. Therefore you would
>> use:
>>
>> output=data[xF,yF,*]
>>
>> Not sure if you need a "+" or "-" for your Degree coordinates
>> indicating North/South(Latitude) or East/West(Longitude).
>>
>> Hope this helps.
>>
>> Pete
>
Re: Problem with ENVI_CONVERT_File_COORDINATES [message #58899 is a reply to message #58833] Tue, 26 February 2008 07:21 Go to previous messageGo to next message
Chris Jengo is currently offline  Chris Jengo
Messages: 13
Registered: July 1999
Junior Member
You may also want to check out ENVI_GET_SLICE, since it will allow you
to retrieve values for all bands for a single pixel (or row of pixels)
without having to read the entire cube into memory.

Chris
Re: Problem with ENVI_CONVERT_File_COORDINATES [message #58911 is a reply to message #58833] Tue, 26 February 2008 00:18 Go to previous messageGo to next message
wita is currently offline  wita
Messages: 43
Registered: January 2005
Member
Hi,

Pete is correct. You should use:

output=data[xF,yF,*]

I tried the ENVI routine and it works perfectly well in converting
file coordinates to map coordinates and vice-versa.

Allard
Re: Problem with ENVI_CONVERT_File_COORDINATES [message #58963 is a reply to message #58899] Tue, 26 February 2008 17:04 Go to previous message
Wasit.Weather is currently offline  Wasit.Weather
Messages: 62
Registered: February 2008
Member
Hi all,
It worked. Thanks. To get pixel values by long/lats, one need to
change the coordinate to map coordinate first by calling
ENVI_CONVERT_PROJECTION_COORDINATES
then use
ENVI_CONVERT_File_COORDINATES, fid, xF, yF,xcoord, ycoord

output=data[xF,yF,*]

On Feb 26, 9:21 am, Chris Jengo <cje...@gmail.com> wrote:
> You may also want to check out ENVI_GET_SLICE, since it will allow you
> to retrieve values for all bands for a single pixel (or row of pixels)
> without having to read the entire cube into memory.
>
> Chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Create an ENVI .img file
Next Topic: Three dimensional Polyfillv

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

Current Time: Wed Oct 08 13:41:55 PDT 2025

Total time taken to generate the page: 0.00705 seconds