首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用R列出LANDSAT文件的一些波段

使用R列出LANDSAT文件的一些波段
EN

Stack Overflow用户
提问于 2018-04-20 15:51:38
回答 1查看 109关注 0票数 1

我有一个文件夹与一个陆地卫星图像与8个tif文件。

代码语言:javascript
复制
list.files("C:/Users/Documents/04.HUMEDALES/L5__002072-09MAY-2006",  pattern = glob2rx("*.TIF"),full.names = TRUE) 

如图所示:

代码语言:javascript
复制
[1] "C:/Users/Documents/L5__002072-09MAY-2006/LT05_L1TP_002072_20060509_20161121_01_T1_B1.TIF" 
[2] "C:/Users/Documents/L5__002072-09MAY-2006/LT05_L1TP_002072_20060509_20161121_01_T1_B2.TIF" 
[3] "C:/Users/Documents/L5__002072-09MAY-2006/LT05_L1TP_002072_20060509_20161121_01_T1_B3.TIF" 
[4] "C:/Users/Documents/L5__002072-09MAY-2006/LT05_L1TP_002072_20060509_20161121_01_T1_B4.TIF" 
[5] "C:/Users/Documents/L5__002072-09MAY-2006/LT05_L1TP_002072_20060509_20161121_01_T1_B5.TIF" 
[6] "C:/Users/Documents/L5__002072-09MAY-2006/LT05_L1TP_002072_20060509_20161121_01_T1_B6.TIF" 
[7] "C:/Users/Documents/L5__002072-09MAY-2006/LT05_L1TP_002072_20060509_20161121_01_T1_B7.TIF" 
[8] "C:/Users/Documents/L5__002072-09MAY-2006/LT05_L1TP_002072_20060509_20161121_01_T1_BQA.TIF"

我怎么能只列出乐队1到5和7的tif文件?我找不到合适的图案。这是我得到的最接近的文件(只删除最后一个文件: BQA.tif)

代码语言:javascript
复制
list.files("C:/Users/Documents/04.HUMEDALES/L5__002072-09MAY-2006", pattern = glob2rx("*B?.TIF"), full.names = TRUE)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-20 16:03:49

从这组文件中:

代码语言:javascript
复制
> list.files(".")
 [1] "bar-foo_B1.tif"  "bar-foo_B2.tif"  "bar-foo_B3.tif"  "bar-foo_B4.tif" 
 [5] "bar-foo_B5.tif"  "bar-foo_B6.tif"  "bar-foo_B7.tif"  "bar-foo_BQA.tif"
 [9] "foo_B1.tif"      "foo_B2.tif"      "foo_B3.tif"      "foo_B4.tif"     
[13] "foo_B5.tif"      "foo_B6.tif"      "foo_B7.tif"      "foo_BQA.tif"    

我可以使用此正则表达式进行选择,该正则表达式匹配任何内容(.*)、B、1至5和7,然后是".tif“,然后是文件名的末尾:

代码语言:javascript
复制
> list.files(".",pattern=".*B[123457]\\.tif$", ignore.case=TRUE)
 [1] "bar-foo_B1.tif" "bar-foo_B2.tif" "bar-foo_B3.tif" "bar-foo_B4.tif"
 [5] "bar-foo_B5.tif" "bar-foo_B7.tif" "foo_B1.tif"     "foo_B2.tif"    
 [9] "foo_B3.tif"     "foo_B4.tif"     "foo_B5.tif"     "foo_B7.tif"    
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49945474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档