惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - homegis

关于开源GIS和商业GIS的讨论 B树索引学习 cordova 开发 ios app 简要流程 cordova 开发 android app 简要流程 3D开源推荐:3DWebExplorer 3D开源推荐:全球卫星地图 Esri-Satellite-Map 空间网络分析开源环境的安装方法 Computing Aggregate Queries in Raster Image Databases Using Pre-Aggregated Data Cheetah:A High Performance, Custom Data Warehouse on Top of MapReduce 【转】 Ubuntu内核编译 Fuzzy C-Means Clustering【转】 【转】什么是数据驱动编程 DISPLAY connection problem when using ENVI/IDL in X Terminal LINUX 上 ENVI 4.7 安装步骤,IDL 调用方式 图论——网络最大流和最小截 Gfarm 安装(已测试) [转]多表连接的三种方式详解 HASH JOIN MERGE JOIN NESTED LOOP VS2005 调用 IDL7.1 方法 [转] 如何下载Google Earth中的卫星影像
【转】Envi调用MODIS Reprojection Tool(MRT)对MODIS产品进行批处理拼接、重投影、裁切 - homegis
homegis · 2009-12-20 · via 博客园 - homegis

1 熟悉MRT

MODIS产品的类型不同,一景HDF格式的影像包含的波段也各不相同。MRT处理时需要选择处理波段,0表示不作处理,1表示处理,首先要确定影像的波段数。

1、拼接

Mrtmosaic.exe程序用来拼接影像。调用方式为:

mrtmosaic -i "g:\n%1.txt" -s " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 " -o "g:\temp.hdf"

命令行帮助如下

Usage: mrtmosaic -i input_filenames_file -t -h -o output_filename

                 -s spectral_subset "b1 b2 ... bN"

                 -g filename for the log file

需要指定三个参数:

-I 指定输入文件,可以采取两种方式

11.hdf 2.hdf 3.hdf

2、把影像的完整路径保存到txt文件中,作为input参数。如-I MOD092008001.txt

-s 指定需要处理的波段,同样可以采用两种方式

1、直接给出,如 –s “0 0 0 0 0 0 0 0 0 0 0 0”,注意英文引号;

2、指定一个txt路径,让程序读取;

-o 指定输出路径,一般直接给出

1、直接给出,如 –o g:\tmp.hdf。注意直接存为HDF格式,便于后续处理。

2、重投影、裁切

Resample.exe用来重投影、裁切是MRT程序的核心。调用方式为:

命令行帮助如下:

Usage: resample -p parameter_file [options]

Options that override parameter file specifications:

   -i input_file_name

   -o output_file_name

   -r resampling_type [NN BI CC NONE]

   -t projection_type [AEA ER GEO HAM IGH ISIN LA LCC MERCAT MOL PS SIN TM UTM]

   -j projection_parameter_list "p1 p2 ... p15"

   -s spectral_subset "b1 b2 ... bN"

   If using the -s switch, the SDSs should be represented as an

   array of 0s and 1s. A '1' specifies to process that SDS;

   '0' specifies to skip that SDS. Unspecified SDSs will not be processed.

   If the -s switch is not specified, then all SDSs will be processed.

   -a spatial_subset_type [INPUT_LAT_LONG INPUT_LINE_SAMPLE OUTPUT_PROJ_COORDS]

   -l spatial_subset "ULlat ULlong LRlat LRlong"

               -or- "ULline ULsample LRline LRsample (0-based)"

               -or- "ULprojx ULprojy LRprojx LRprojy"

      NOTE: line/sample must be specified for the             highest resolution

 of all SDSs specified             to be processed in the product.

   -u UTM_zone

   -x pixel_size

   -g filename for the log file

可以只指定1个参数:

–p 读入prm参数文件,进行处理。例如resample -p "g:\prrmMOD092008001.prm"prm文件如下:

INPUT_FILENAME = g:\tmp_%1.hdf输入文件

SPECTRAL_SUBSET = ( 1 1 1 1) 前面mrtmosaic拼接结果有4个波段

SPATIAL_SUBSET_TYPE = INPUT_LAT_LONG 经纬度裁切方式

SPATIAL_SUBSET_UL_CORNER = ( 33.0 108.0 ) 左上纬经度

SPATIAL_SUBSET_LR_CORNER = ( 28.0 117.0 ) 右下纬经度

OUTPUT_FILENAME = F:\MRT_out\myd%1.tif 输出路径,不同波段自动区分

RESAMPLING_TYPE = NEAREST_NEIGHBOR 最近邻采样方法

OUTPUT_PROJECTION_TYPE = UTM 输出文件投影方式utm

OUTPUT_PROJECTION_PARAMETERS = (投影参数

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0 )

DATUM = WGS84 大地水准面

UTM_ZONE = 50投影分带带号

如果不会设置,可以先在图形界面里设置一次,把设置的结果保存下来。

打开刚刚保存的参数文件

去掉以#号打头的注释,文件显示如下:

INPUT_FILENAME = G:\TmpMosaic.hdf

SPECTRAL_SUBSET = ( 1 1 1 1 1 1 1 1 1 1 1 1 )

SPATIAL_SUBSET_TYPE = INPUT_LAT_LONG

SPATIAL_SUBSET_UL_CORNER = ( 32.0 107.0 )

SPATIAL_SUBSET_LR_CORNER = ( 29.0 116.0 )

OUTPUT_FILENAME = G:\mod092001001.tif

RESAMPLING_TYPE = NEAREST_NEIGHBOR

OUTPUT_PROJECTION_TYPE = UTM

OUTPUT_PROJECTION_PARAMETERS = (

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0 )

DATUM = WGS84

UTM_ZONE = 50

如果研究区的经纬度范围不同,可以修改

SPATIAL_SUBSET_UL_CORNER = ( 32.0 107.0 )

SPATIAL_SUBSET_LR_CORNER = ( 29.0 116.0 )两行

如果需要不同的投影,如经纬度投影,可以修改

OUTPUT_PROJECTION_TYPE = UTM

OUTPUT_PROJECTION_PARAMETERS = (

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0

 0.0 0.0 0.0 )

DATUM = WGS84

UTM_ZONE = 50

如果拼接时只选择了1个波段,可以修改

SPECTRAL_SUBSET = ( 1 )

当然这句

INPUT_FILENAME = G:\TmpMosaic.hdf批处理是必须改掉的了

关于像素分辨率,一般留空,也就是默认不改变影像的像素大小。

2关于DOS批处理裁切MOD产品

单次处理

Dir g:\mod11*A%1*.hdf /s /b >> g:\n%1.txt

f:\mrt\modis\bin\mrtmosaic -i "g:\n%1.txt" -s " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 " -o "g:\temp_%1.hdf"

f:\mrt\modis\bin\resample -p "g:\prm%1.prm"

del g:\prm%1.prm /q /f

del g:\n%1.txt /q /f

del g:\temp_%1.hdf /q /f

批量处理

for /f %%i in (e:\lis.txt) do @单次处理文件名 %%i

如果双击运行,用%%i号表示变量。在命令行中%i表示变量。

其中e:\lis.txt是年份及天数

2008001

2008009

2008017

2008025

2008033

2008041

2008049

G:\n%1.txt在运行时为g:\n2008001.txt,其中包括2008年第1天的多景MODIS产品影像名。

Dir g:\mod11*A%1*.hdf /s /b >> g:\n%1.txt

用来列出g盘(数据存储盘)以mod11打头的指定日期的的hdf格式文件,即MODIS影像。

这里要说明一下,MODIS产品命名的规则

MYD11A2.A2002185.h27v05.005.2007221162948.hdf

从左至右,前7位表示产品类型MYD11指下午星(MYD)11号产品(land surface temperature),A2表示处理级别。A2002185表示过境时间是2002年第185天,h27v05MODIS产品在全球的轨道行列号,中国一般是h27v05h27v06h28v05h28v06005表示HDF5文件格式,早期MODIS采用HDF4格式存储,所以有时也可见到004的产品。2007等一串数字表示影像处理的年月日时分秒,hdf表示存储格式为EOS-HDF

了解了MODIS产品命名规则之后,可以用DOS dir命令来挑选符合条件的MODIS产品路径了。

>> g:\n%1.txt 表示把结果转存为g:\n%1.txt

%1表示接收的第一个参数,即2008001

3Envi生成时间列表

2008001

2008009

2008017

2008025

这样的列表文件可以用在Envi中定义一个pro来生成:

pro daylist,startdate,enddate,result_txt_path

        ;example daylist,2008001,2008013,'example.txt'

        ;

        ;

        a=(startdate mod 1000) /8 *8+(startdate /1000)*1000+1

        b=((enddate mod 1000) /8 +1)*8+(enddate /1000)*1000+1

        help,a,b       

        step=8

        openw,lun,result_txt_path,/get_lun

        res=a;     

        for i=a,b,step do begin

            printf,lun,string(res,format='(%"%7d")')

            res=res+step

        endfor

        free_lun,lun

        print,'done';

        close,/all

end

在命令行窗口敲入

daylist,2009001,2009033,'f:\g4.txt'

打开f:\g4.txt如下:

2009001

2009009

2009017

2009025

2009033

2009041

4Envi平台下整合前面工作

留给读者思考

 提示:spawn函数