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

Home » Public Forums » archive » ENVI Navigating GeoTiff Image Incorrectly?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
ENVI Navigating GeoTiff Image Incorrectly? [message #78134] Wed, 26 October 2011 14:08 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

Has anyone ever compared ENVI's map projection routines
with IDL's? (I am speaking about Map_Proj_Init, not
Map_Set.)

I have spent the past couple of days working with
a GeoTiff image and my active contouring software.
I am trying to produce output that matches the output
from ENVI. I know, for example, that ENVI counts from
1 and not 0, and that the origin is in the upper left
corner (where it is suppose to be!) and not in the
lower left corner as in IDL.

But, even so, I have not been able to reconcile my
results with ENVIs. And now I have come to the
conclusion that ENVI is just plain wrong. :-)

Here is what I have done. I have a GeoTiff image
(which I can provide, if anyone is interested). And,
Lord knows, I *know* how to navigate a GeoTiff image!

You get the tie points, which locate the upper-left
corner of the upper left pixel. This locates the upper
and left boundary of the image. Then you read the
X and Y pixel scales out of the Tiff file. I my
case, these are both 2.0 meters (a pixel is 2 meters
square). If you multiply the size of the image by
the pixel scales, you will obtain a value that marks
the lower and right boundaries of the image.

Consider a 10x10 image that used 1 meter scales.
If the upper-left corner of the upper-left pixel
was located at (0,0), then the lower-right corner
of the lower-right pixel would be located like this:

s = Size(image, /Dimensions)
x1 = x0 + s[0]*xscale
y1 = y0 + s[1]*yscale

IF x0 and y0 were equal to 0, and xscale and yscale were
equal to 1, then the (x1,y1) point would be (10,10).
You would say the boundaries of this image were 0 and 10
in both X and Y directions.

This is *exactly* what I do for the GeoTiff image. In my
image the tie point (x0,y0) is located at (519279,7443030),
and I calculate the (x1,y1) location for this 800x800 image
as (520879,7441430). Note that if you subtract these values,
you get 1600 in both X and Y dimensions, as you would expect.

ENVI, uses the very same (x0,y0) point, but calculates the
(x1,y1) point as (520877,7441432). In other words, ENVI is
one pixel short in X and one pixel long in Y!! (To get the
ENVI values, I used the Pixel Locator and entered 800 in both
the Sample and Line positions.)

But, my interest was really in locating an ROI in the
image. To investigate this, I made a sample feature
by creating a 25 pixel on a side square near the center of
the image. And then I calculated the projected XY locations
of the four corner pixels of this sample feature.

If you assume that the pixel index number identifies the
center of each pixel, then you could investigate the size
of the feature by subtracting the projected XY locations.
When I did this is my code, I found the sample feature to
be 48 meters on a side, exactly as I expected. (Centers,
remember, not edges.)

When I calculated the same values in ENVI I found the feature
to be 48 meters in X, but only 44 meters in Y!!!

I don't have ANY idea how to explain this descrepancy,
except to say I *know* my values are correct and I know
the values I am getting from ENVI are wrong. I conclude
that ENVI is navigating this GeoTiff image incorrectly
which is causing me a great deal of distress when I try
to match these ENVI values! :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: map_proj_init
Next Topic: Re: Shape to raster

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

Current Time: Wed Oct 08 17:36:33 PDT 2025

Total time taken to generate the page: 0.00573 seconds