Re: Finding pixel values of GeoTIFF image based on lat/lon (ENVI and IDL give different results). [message #81960 is a reply to message #81958] |
Mon, 05 November 2012 17:48   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Sobriquet writes:
> Here is what I got:
>
> Image Value: 3085.77
> Nearest Pixel Location (lon/lat):
> Longitude: -148.23405 Image X Coord: 805
> Latitude: 64.699193 Image Y Coord: 1662
>
> What's interesting is that when I input the lat/lons in ENVI it approximates it to the same values that I get when I enter my original lat/lons (64.7000, -148.23300 // 3122). However, when I input the x,y coordinates into ENVI, I get this
>
> (65.4425, -148.09711726 // 3552.166016),
>
> which is very far from my original location. In fact,when I enter the nearest pixel location lat/lons into Google Earth, it lands ~85km away from my input lat/long.
Well, ENVI, remember, uses a different coordinate system than
IDL does. Theirs starts at 1, IDL's starts at 0.
> Now, I know ENVI is not perfect. A quick survey on Google Earth also shows that the approximation of the location I entered is about 100 m off.
Did you convert your coordinate from an Albers projection to the
Equirectangular projection used by Google Earth? If not, this
can account for differences of at least 100 meters, depending
upon where you are on the Earth.
> I think the problem is that since the resolution of the arrays is very high (100 m), there are a lot of possible matches in the position vectors. Value_Locate is searching through the u and v vectors individually and finding the closest match for each value without taking into account the relationship between the two vectors,i.e., it is not finding the closest u match in relation to the v match that together make the nearest point possible to the input values. As a
result, you might get very close u and v individual matches for your input lat/lon that translate into a very off pair of sample/line values in your pixel coordinates.
On the contrary, there is only one possible match on this grid. It is
true that the actual location of the grid crossing point can be off from
the true location of your point by at something like 100 meters (if this
is the size of the grid), but there are not "multiple" matches. There is
one possible match to a particular point.
> I hate to be a stickler, but is there a way to establish a relationship between the two position vectors that would help solve the ambiguity?
Value_Locate is finding the index of the value that is closest to your
chosen point that doesn't exceed your point value. You could subtract
the grid value from your point, and if it is larger than half a grid
size, you could say the next index is closer than the one Value_Locate
found.
xindex = Value_Locate(uvec, pt_x)
IF pt_x = uvec[xindex] > (uvec[1]-uvec[0])/2 THEN xindex = xindex + 1
I guess it depends on how anal you want to be. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
|
|
|