X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 24 Feb 2008 09:17 AM by  anon
Problem with ENVI_CONVERT_File_COORDINATES Options
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
24 Feb 2008 09:17 AM
    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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    24 Feb 2008 09:17 AM
    If Geographic Lat/Lon is not the native projection of the file when opened in ENVI, then you will not get the correct image coordinates when using geographic coordinates as your xmap and ymap in ENVI_CONVERT_FILE_COORDINATES. You need to use the map coordinates of the file. For example, if your file is in UTM coordinates, then your xmap and ymap need to be in easting and northings. xmap = 279015.0 ymap = 4899765.0 envi_convert_file_coordinates, fid, xf, yf, xmap, ymap If you wish to extract image coordinates by geographic lat/lon location, then you will need to convert your geographic coordinates to map coordinates via ENVI_CONVERT_PROJECTION_COORDINATES before calling ENVI_CONVERT_FILE_COORDINATES so that your xmap and ymap are in the correct map coordinates.
    You are not authorized to post a reply.