菜鸟速成记-IDL读取显示dat文件
2017-05-23 15:03
931 查看
DAT文件的读取
问题描述
之前,博主没有理解dat文件导致对文件获取产生问题和误解,还可笑的认为没办法获取demission的话,是没有办法读取dat文件的。由于dat文件是遥感影像的常用格式之一。所以,首先认识一番,dat文件。
先找个文件夹看看它在哪
2.看看它们到底长什么样子
hdr 头文件
dat 文件
3.思考怎么去读取dat文件
读取dat文件的思路:
- 首先获取到dat文件的头文件信息。
调用函数进行显示READ_BINARY()
代码实现过程
由于代码实现过于简单,所以没有写相应的注释,有什么不会的直接留言~pro read_dat hdr_path=DIALOG_PICKFILE(/READ) hdr_path=string(hdr_path) head_info=strarr(6) openr,lun,hdr_path,/get_lun readf,lun,head_info ;print,head_info free_lun,lun I=5; while (i gt 0) do begin temp=string(head_info[i]) IF(temp.contains('samples'))THEN BEGIN xs=temp ENDIF IF(temp.contains('bands'))THEN BEGIN band=temp ENDIF IF(temp.contains('lines'))THEN BEGIN ys=temp ENDIF IF i GT 5 THEN BEGIN BREAK ENDIF i-- endwhile ;print,head_info[j] ;xs=string(head_info[3]) xs=xs.split("=") xs=xs[1] ;ys=string(head_info[4]) ys=ys.split("=") ys=ys[1] ;band=string(head_info[4]) band=band.split("=") band=band[1] img_path=dialog_pickfile(/read) img_path=string(img_path) imageSize=[uint(xs),uint(ys)] mbells = READ_BINARY(img_path, DATA_DIMS = imagesize) ; TrueColor display DEVICE, DECOMPOSED = 0 LOADCT, 0 WINDOW, 0, XSIZE = imageSize[0], YSIZE = imageSize[1], $ TITLE = 'A Binary Image, Scaled' TVSCL, mbells end
代码实现的效果
灰度图实现效果
送你们个惊喜
国外优秀网站在GIS的沙场,传播有价值的东西!
相关文章推荐
- 一段读取文件时显示进度条的代码(CSDN上收录)
- PHP 操作 XML 文件 - 读取、显示
- asp.net中将图片或文件存入数据库并读取显示在image控件中
- 读取磁盘图片文件并显示
- 读取excel文件显示在gridview中数据.字符.数字混合时无法全部读取的问题!
- displaytag中列名显示为中文(从资源文件中读取)
- IDL学习笔记(3)--hdf文件SDS读取并显示为图片
- 读取磁盘图片文件并显示
- 一段读取文件时显示进度条的代码(CSDN上收录)
- 从一个txt文件中读取文章并删除特定单词并显示文章
- PHP 操作 XML 文件 - 读取、显示
- [转载]VC6.0中使用Stream Object读取数据中流文件并显示Bmp,JPG等
- PHP 操作 XML 文件 - 读取、显示
- qt4:读取硬盘上的文件并显示到文本框中,
- jsp读取txt文件后,将txt文件内容分页显示
- PHP 操作 XML 文件 - 读取、显示
- 如何从文件读取显示位图?
- 使用Robot从txt文件中读取不同行的内容并显示(续)
- C语言读取和显示BMP文件
- VS2008经过UltraISO编辑后出现 deffactory.dat等文件不能读取的问题之解决