最近需要处理连续10年的MODIS LAI产品数据(MOD15A2)。根据自己的需求,写了一个MS-DOS批处理小程序,主要解决的问题是:YEAR和DOY两重循环,并将YEAR和DOY连接成YEAR+DOY的形式(如2001001)用以搜索符合条件的待拼接文件。 需要注意的地方(代码中红色标注处): 1、用set设置数据文件夹环境变量时,等号的前后都不能出现空格。如果等号前面有空格,则环境变量名称变为“MRTDATADIR ”,如果等号后有空格,则数据文件夹路径前面多出空格会导致MRT工具找不到相关数据文件。 2、DOY的设置采用了“曲线救国”方案,即先设置为10001的形式,然后截取最后三个字符作为标准DOY。 3、DOS下的字符截取操作:%DOY:~-3%表示截取DOY变量的最后三个字符,等效于%DOY:~4,3%,表示从DOY变量的第5个字符开始截取3个字符。 4、进行YEAR的循环时需要对DOY进行初始化。 代码如下: @echo off rem **This is a MS-DOS batch file to do multi-yearly mosaicing and resampling preprocessing by using MRT rem **author: pengbin, institute of remote sensing and digital earth, CAS rem **Memo: developed at May 7th, 2013 rem **Set the MRTDATADIR environmental var to the MRT data directory. set MRTDATADIR=D:\MOD15A2_h24-26_v4-5 rem **set batch data start time set /a YEAR = 2001 set /a DOY = 10001 rem **set batch data end time set /a ENDYEAR = 2010 set /a ENDDOY = 10365 :start if %YEAR% leq %ENDYEAR% (goto ORDER1) else exit :ORDER1 if %DOY% leq %ENDDOY% (goto ORDER2) else ( set /a YEAR = %YEAR% +1 set /a DOY = 10001 goto start ) :ORDER2 set /a DAY = %YEAR%%DOY:~-3% rem **save the file name into a notepad dir %MRTDATADIR%\*%DAY%.*.hdf/a/b/s %MRTDATADIR%\MOSAICINPUT.TXT rem **execute mosaic mrtmosaic.exe -i %MRTDATADIR%\MOSAICINPUT.TXT -o %MRTDATADIR%\MOSAIC_TMP.hdf rem **execute resample resample.exe -p %MRTDATADIR%\MOD15A2.prm -i %MRTDATADIR%\MOSAIC_TMP.hdf -o %MRTDATADIR%\%DAY%.tif set /a DOY = %DOY% + 8 goto ORDER1
New MRT Release The Land Processes Distributed Active Archive Center (LP DAAC) announces the release of a new version of the MODIS Reprojection Tool (MRT) application. MRT v4.1 incorporates bug fixes and resolution of issues identified by users since the last release in 2008. Please see the Release Notes for details. Download, installation, and execution assistance is available from LP DAAC User Services. https://lpdaac.usgs.gov/lpdaac/tools/modis_reprojection_tool NASA Land Processes Distributed Active Archive Center User Services USGS Earth Resources Observation and Science (EROS) 47914 252nd Street Sioux Falls, SD 57198-0001 Voice: 605-594-6116 Toll Free: 866-573-3222 Fax: 605-594-6963 E-mail: LPDAAC@usgs.gov Web: https://LPDAAC.usgs.gov