Sobriquet
2012-11-05 17:47:14 UTC
Hi,
I know this is a relatively simple task but I'm still new to IDL and have been unable to find an appropriate answer to the problem.
I have ~700 GeoTIFF images of dimensions around 4000x4000.I have the lat/long coordinates of 9 points from which I need to extract information. The images are projected on the Albers Conical Equal Area projection. I need to find the closest pixel value (sample, line image coordinates) that matches the lat/lon pairs. I previously used the approach described here: http://www.idlcoyote.com/map_tips/pixel_to_ll.html
However, I was unable to find a matching pair of lat/long in both arrays or convert the closest match between the two to pixel coordinates.
I, then, tried searching through the images using this code:
RES = 100./1.
IMGDATA = READ_TIFF(data_FILES[I], IMAGE_INDEX = 0, GEOTIFF = geotag)
S = SIZE(IMGDATA, /DIMENSIONS); image size
FILE_POS_data = STRSPLIT(data_FILES[I], '\', /EXTRACT, COUNT = POS_data)
FILE_NAME = STRMID(FILE_POS_data[POS_data-1], 0, 15)
RESOLUTION = geotag.MODELPIXELSCALETAG[0] / RES
xmin = geotag.MODELTIEPOINTTAG[3] / RES
ymax = geotag.MODELTIEPOINTTAG[4] / RES
ymin = ymax - (N_ELEMENTS(IMGDATA[0,0,*])) * resolution
PTLAT = my_lat
PTLON = my_lon
alberMap = MAP_PROJ_INIT('Albers Equal Area Conic', $
DATUM=8, $ ; WGS84
SPHERE_RADIUS = 6378137.0, $ ; Earth's equatorial radius, or semi-major axis according to WGS-84
CENTER_LAT=geotag.PROJNATORIGINLATGEOKEY, $
CENTER_LON=geotag.PROJNATORIGINLONGGEOKEY, $
STANDARD_PAR1=geotag.PROJSTDPARALLEL1GEOKEY, $
STANDARD_PAR2=geotag.PROJSTDPARALLEL2GEOKEY)
result = MAP_PROJ_FORWARD(ptlon, ptlat, MAP_STRUCTURE=alberMap)
ptx = result[0, *]/RES
pty = result[1, *]/RES
x = FLOOR((ptx - xmin ) / resolution)
y = -(FLOOR((pty - ymin) / resolution))
PRINT, x,y,resolution
results = IMGDATA[x-1,y-1]
The problem is that when I double check the results using the same latitude and longitude in ENVI I get different results/pixels.
For example, when I input the my_lat/my_lon pair (64.7000, -148.23300) in the IDL code, I get a pixel value of 3164 and a sample/line value of 805, 2501. However, when I open the image in ENVI and change the projection to lat/lon, I get a pixel value of 3122, and a sample/line value of 813,2495. This might be different because ENVI could be using a different reprojection scheme than IDL.
When I check for the lat/lons that get approximated for the sample/line combinations in ENVI, I get that:
My_lat, mylon = 64.7000, -148.23300
ENVI 813, 2495 = 64.7002, -148.2349
IDL 805, 2501 = 64.6955, -148.2527
ENVI gives me more precise results, and although a difference between 3164 and 3122 is relatively small, other images and coordinate pairs give me more wildly varying results (some have a difference of 1500, 2000).
My questions are these:
Is there any method to reconcile this discrepancy in my IDL code?
What is the reprojection scheme that ENVI uses to change from ALBERS to lat/lon, and that could explain the difference?
Any suggestions would be greatly appreciated.
Thanks.
I know this is a relatively simple task but I'm still new to IDL and have been unable to find an appropriate answer to the problem.
I have ~700 GeoTIFF images of dimensions around 4000x4000.I have the lat/long coordinates of 9 points from which I need to extract information. The images are projected on the Albers Conical Equal Area projection. I need to find the closest pixel value (sample, line image coordinates) that matches the lat/lon pairs. I previously used the approach described here: http://www.idlcoyote.com/map_tips/pixel_to_ll.html
However, I was unable to find a matching pair of lat/long in both arrays or convert the closest match between the two to pixel coordinates.
I, then, tried searching through the images using this code:
RES = 100./1.
IMGDATA = READ_TIFF(data_FILES[I], IMAGE_INDEX = 0, GEOTIFF = geotag)
S = SIZE(IMGDATA, /DIMENSIONS); image size
FILE_POS_data = STRSPLIT(data_FILES[I], '\', /EXTRACT, COUNT = POS_data)
FILE_NAME = STRMID(FILE_POS_data[POS_data-1], 0, 15)
RESOLUTION = geotag.MODELPIXELSCALETAG[0] / RES
xmin = geotag.MODELTIEPOINTTAG[3] / RES
ymax = geotag.MODELTIEPOINTTAG[4] / RES
ymin = ymax - (N_ELEMENTS(IMGDATA[0,0,*])) * resolution
PTLAT = my_lat
PTLON = my_lon
alberMap = MAP_PROJ_INIT('Albers Equal Area Conic', $
DATUM=8, $ ; WGS84
SPHERE_RADIUS = 6378137.0, $ ; Earth's equatorial radius, or semi-major axis according to WGS-84
CENTER_LAT=geotag.PROJNATORIGINLATGEOKEY, $
CENTER_LON=geotag.PROJNATORIGINLONGGEOKEY, $
STANDARD_PAR1=geotag.PROJSTDPARALLEL1GEOKEY, $
STANDARD_PAR2=geotag.PROJSTDPARALLEL2GEOKEY)
result = MAP_PROJ_FORWARD(ptlon, ptlat, MAP_STRUCTURE=alberMap)
ptx = result[0, *]/RES
pty = result[1, *]/RES
x = FLOOR((ptx - xmin ) / resolution)
y = -(FLOOR((pty - ymin) / resolution))
PRINT, x,y,resolution
results = IMGDATA[x-1,y-1]
The problem is that when I double check the results using the same latitude and longitude in ENVI I get different results/pixels.
For example, when I input the my_lat/my_lon pair (64.7000, -148.23300) in the IDL code, I get a pixel value of 3164 and a sample/line value of 805, 2501. However, when I open the image in ENVI and change the projection to lat/lon, I get a pixel value of 3122, and a sample/line value of 813,2495. This might be different because ENVI could be using a different reprojection scheme than IDL.
When I check for the lat/lons that get approximated for the sample/line combinations in ENVI, I get that:
My_lat, mylon = 64.7000, -148.23300
ENVI 813, 2495 = 64.7002, -148.2349
IDL 805, 2501 = 64.6955, -148.2527
ENVI gives me more precise results, and although a difference between 3164 and 3122 is relatively small, other images and coordinate pairs give me more wildly varying results (some have a difference of 1500, 2000).
My questions are these:
Is there any method to reconcile this discrepancy in my IDL code?
What is the reprojection scheme that ENVI uses to change from ALBERS to lat/lon, and that could explain the difference?
Any suggestions would be greatly appreciated.
Thanks.