X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 16 Nov 2007 03:16 PM by  anon
Writing to HDF-EOS files in IDL6.3
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
16 Nov 2007 03:16 PM
    Hi, I posted this on the ENVI forum, but have just realised that the HDF-EOS commands are part of standard IDL, so hopefully someone here can help me out! I have been trying to modify a geofield in a MODIS HDF-EOS file with the following code: (infile is a string with the location of the .hdf) nswath = eos_sw_inqswath(infile, swath_list) swath_name = strsplit(swath_list, ',', /extract) fid = eos_sw_open(infile, /rdwr) swath_id = eos_sw_attach(fid, swath_name[0]) geofield_count = eos_sw_inqgeofields(swath_id, geofield_list, geofield_ranks, geofield_types) geofield_names = strsplit(geofield_list, ',', /extract) name=geofield_names[0] print,name result = eos_sw_detach(swath_id) swath_id = eos_sw_attach(fid, swath_name[0]) status = EOS_SW_DEFDIM(swath_id, "GeoTrack", 2000) status = EOS_SW_DEFDIM(swath_id, "GeoXTrack", 2200) status = EOS_SW_WRITEGEOMETA(swath_id,name, "GeoTrack,GeoXtrack", 5) print,status result = eos_sw_detach(swath_id) swath_id = eos_sw_attach(fid, swath_name[0]) geofield_count = eos_sw_inqgeofields(swath_id, geofield_list, geofield_ranks, geofield_types) print,geofield_list result=eos_sw_close(fid) However, I am having a bit of a problem. Rather than overwriting the previous geofield the EOS_SW_WRITEGEOMETA command seems to be creating an entirely new one with the same name. I compared geofield_list pre- and post- calling this command and before I have this output: Latitude, Longitude After calling eos_sw_writegeometa I get this: Latitude, Longitude, Latitude Could someone point me in the direction of what I've done wrong here? I'm guessing I have overlooked something simple! I'm also not sure about the detach and attach commands, I've tried various combinations of positions and numbers of calls, but they don't seem to make much difference. I've left them in the above code, though. Thanks, Simon.

    Deleted User



    New Member


    Posts:
    New Member


    --
    16 Nov 2007 03:16 PM
    When making changes like this, it is often easier to work with the HDF interface at the Scientific Dataset level. If I'm understanding your issue correctly, the following modified version of your code should do what you want: nswath = eos_sw_inqswath(infile, swath_list) swath_name = strsplit(swath_list, ',', /extract) fid = eos_sw_open(infile, /rdwr) swath_id = eos_sw_attach(fid, swath_name[0]) geofield_count = eos_sw_inqgeofields(swath_id, geofield_list, geofield_ranks, geofield_types) geofield_names = strsplit(geofield_list, ',', /extract) name=geofield_names[0] print,name result = eos_sw_detach(swath_id) result = EOS_EH_IDINFO(fid, HDFfid, sdInterfaceID) geo_index = hdf_sd_nametoindex(sdInterfaceID, name) datasetID = hdf_sd_select(sdInterfaceID, geo_index) hdf_sd_attrset, datasetID, 'GeoTrack', 2000 hdf_sd_attrset, datasetID, 'GeoXTrack', 2200 result = eos_sw_detach(swath_id) swath_id = eos_sw_attach(fid, swath_name[0]) geofield_count = eos_sw_inqgeofields(swath_id, geofield_list, geofield_ranks, geofield_types) print,geofield_list result=eos_sw_close(fid) By the way, if you haven't found it already, you might want to try out the MODIS Conversion Toolkit on our Code Contribution site. It takes all of the guesswork out of working with MODIS data: https://www.ittvis.com/codebank/search.asp?FID=485
    You are not authorized to post a reply.