Re: ENVI_CONVERT_FILE_COORDINATES returning negative values [message #53954 is a reply to message #53947] |
Fri, 11 May 2007 06:42   |
Jeff N.
Messages: 120 Registered: April 2005
|
Senior Member |
|
|
On May 11, 1:00 am, hanneli...@yahoo.co.uk wrote:
> Hi everyone, I'm a new ENVI/IDL user and hope to get some help here
>
> I am attempting to extract 3x3 pixel windows from MODIS images using
> lat/long coordinates. To do this I have
> -created two variables containing the latitude and longitude of the
> area I want to extract
> - opened the relevant image file (which has a related .hdr file with
> the map info of the image)
> - used the command [ENVI_CONVERT_FILE_COORDINATES, fid, XF, YF,
> xcoord, ycoord] to change from lat/long coordinates to pixel values
> (the xcoord= -35.406368 and ycoord=149.80322, XF and YF output was
> -30954 and -34019 respectively)
> - used the XF and YF output values to extract the 3x3 pixel window
> e.g.
> Output[0] = xcoord
> Output[1] = ycoord
> Output[2] = floor(XF)
> Output[3] = floor(YF)
> ; set the extent of the image you want to extract
> dims = [-1, Output[2]-1, Output[2]+1, Output[3]-1, Output[3]+1]
> ; retrieve the pixels
> data = ENVI_GET_DATA(fid=fid, dims=dims, pos=1)
>
> The XF and YF values that are generated are negative and much larger
> than the lines and samples of the image (7451x9580), so I am obviously
> doing something wrong.
>
> The location is in the Southern hemisphere, so the latitude that I
> provided has a negative value (e.g. -35) - I'm sure that is not the
> problem though.
>
> Could it be that the header information of the image is not read
> properly when the file is opened? Is there a way of displaying the map
> info saved in the header when the IDL program is run to check if it is
> read correctly? Or am I on the wrong track?
>
> I would really apprecite any pointers.
> Hannelie
I'm unfamiliar with MODIS data, and also not particularly
knowledgeable with map projections in general, but I have an idea I'll
share nonetheless :) My gut feeling is that your MODIS data are have
had some sort of map projection applied. This would mean that the map
information stored in the file are not geographic coordinates (lat/
lon's), but instead are the coordinates of whatever projection your
data are in. You might want to check the documentation for MODIS data
to verify this. But your statement that the coordinates
ENVI_CONVERT_FILE_COORDINATES is giving you is much larger than the
input image dimensions hints at some sort of map projection to me. If
this is true, after your call to ENVI_CONVERT_FILE_COORDINATES you can
then make a call to ENVI_CONVERT_PROJECTION_COORDINATES to get your
lat/lon values.
Hope that helps,
Jeff
|
|
|