Extract pixel values from HDF-EOS file [message #71832] |
Fri, 23 July 2010 15:17  |
Snow53
Messages: 32 Registered: July 2010
|
Member |
|
|
Hello all. I'm now trying to work with HDF-EOS files. I've been using
the IDL guide as a reference in trying to make this work. My data are
associated with lat, long coordinates. These data originated from
MODIS swath files (HDF4), but were converted to lat/long gridded HDF-
EOS using ModisTool. In reading the IDL guide, it looks like I need to
define the grid system for my file, attatch the grid to my file, and
then I can use EOS_GD_GETPIXVALUES (?) to extract pixel data. I've
tried to set this project up as follows; currently I'm getting stuck
at EOS_GD_CREATE (apparently I haven't created the grid properly).
Would anyone be willing to do a quick read-through and throw out
thoughts or suggestions?
Thanks!
pro hdftest1
; open and extract data from MODIS HDF-EOS file
path = 'X:\MODIS_GPP\Lena\2003\test\'
file_array=file_search(path, '*.hdf', count=num_file)
file=file_array
print, num_file
;print, file
for i=0, num_file-1 do begin
file_name=file_basename(file[i], '.hdf')
;print, file_name
fid=EOS_GD_OPEN(file[i], /READ)
upx=172.763114356
upy=79.9999999993
lrx=116.952175961
lry=69.99999994
ydim=1110
xdim=10239
gridname='geo'
gridID=EOS_GD_CREATE ( fid, gridname, xdim, ydim, [upx, upy], [lrx,
lry]) ; this part isn't working. need to fix. failed .
print, gridID
;gridname=EOS_GD_INQGRID(file[i], gridlist)
;print, gridlist
out=EOS_GD_ATTACH(fid, gridname)
print, out
pixCol=[2,2]
pixRow=[2,2]
result=EOS_GD_GETPIXVALUES (out, 1, pixCol, pixRow,'Gpp_1km', buffer)
print, result
print, buffer
status=EOS_GD_CLOSE(fid)
endfor
end
|
|
|