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

Home » Public Forums » archive » ENVI_CONVERT_FILE_COORDINATES returning negative values
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
ENVI_CONVERT_FILE_COORDINATES returning negative values [message #53958] Thu, 10 May 2007 22:00 Go to next message
hanneliebx is currently offline  hanneliebx
Messages: 2
Registered: May 2007
Junior Member
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
Re: ENVI_CONVERT_FILE_COORDINATES returning negative values [message #54035 is a reply to message #53958] Sat, 12 May 2007 11:25 Go to previous message
devin.white is currently offline  devin.white
Messages: 50
Registered: March 2007
Member
MODIS products generally come in one of two flavors: unprojected
swaths (with geographic lat/lon information stored inside of the HDF)
or projected grids (usually sinusoidal). All Level 1 and most Level 2
products are swaths. All Level 3 and Level 4 products are grids.
Without opening a file to find out, a good general rule of thumb for
determining which kind of product you are dealing with would be:

If the filename starts with MOD01, MYD01, MOD02, MYD02, MOD03, or
MYD03 you are working with swath data. This also applies to prefixes
that look something like this: MOD05_L2. Any prefix that contains
"_L2" is a swath product. When this type of product is opened in
ENVI, there will be no map information present because you are still
working with the data in its original acquisition geometry. To
associate map information with this type of product, the data must be
reprojected by going to Map->Georeference MODIS.

If you can open your data directly in ENVI, and map information is
present, you are probably working with a grid product. You might have
to perform two x/y conversions if you want to find pixel locations
based on geographic coordinates. The first would be to use
ENVI_CONVERT_PROJECTION_COORDINATES to convert your lat/lon values
into x/y sinusoidal coordinates. From there, you can send these new x/
y coordinates into ENVI_CONVERT_FILE_COORDINATES to get your x/y pixel
locations. I just looked at your file size, though, and it seems to
be consistent with a reprojected Level 1B Radiance data cube. If that
is the case, you'll definitely want to switch your x and y values as
was suggested previously, but your image might be projected into UTM
instead of Geographic Lat/Lon (that is the default in ENVI). If so,
you'll still have to do the two x/y conversions to get the file
coordinates you're interested in.

Enhanced support for MODIS data in ENVI is on the way, for those who
might be interested. There is now a plugin for ENVI that can handle
every known data set within every known MODIS product (more than 140
at last count), has the IDL equivalents of MRT and MRTSwath built in,
and has a full programmatic interface--allowing for 100% customized
batch processing of imagery (if desired). It's currently in beta form
and has been distributed for testing within the ENVI user community to
a limited extent. If anyone reading this is interested in becoming a
tester, please send an email to support@ittvis.com with "MODIS
Conversion Toolkit Beta Test" in the subject line. You must have
access to ENVI 4.3 to use the plugin. The plugin will also be able to
handle all known Ocean Color products (available online or generated
through SeaDAS), but that part is not quite done yet. When everything
is complete, it will be available through the ITT VIS Code
Contribution site at first, but might end up as part of ENVI's core
distribution in the long run.


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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Z Profile
Next Topic: Extracting zeros from array

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

Current Time: Wed Oct 08 20:02:51 PDT 2025

Total time taken to generate the page: 0.05005 seconds