如何在 R 中打开/读取 ENVI 文件

问题描述

我是在 R 中使用 GIS 的新手,我正在尝试按照这篇文章 R how to read ENVI .hdr-file? 的建议打开一个包含高光谱数据的 ENVI 文件,但我似乎无法这样做。我尝试了三种不同的方法,但都失败了。我似乎也找不到任何其他帖子来描述我的问题。

# install.packages("rgdal")
# install.packages("raster")
# install.packages("caTools")
library("rgdal")
library("raster")
library("caTools")

dirname <- "S:/LAB-cavender/4_Project_Folders/oakWilt/oak_wilt_image_analyses/R_input/6.15.2021 - Revisions/ENVI export/AISA/Resampled_flights"
filename <- file.path(dirname,"AISA_Flight_4_resampled")
file.exists(filename)
  1. 我尝试的第一个选项是仅使用文件
    x <- read.ENVI(filename)

但我收到以下错误消息:

#Error in read.ENVI(filename) :
#  read.ENVI: Could not open input file: S:/LAB-cavender/4_Project_Folders/oakWilt/oak_wilt_image_analyses/R_input/6.15.2021 - Revisions/ENVI export/AISA/Resampled_flights/AISA_Flight_4_resampled
#In addition: Warning message:
#  In nRow * nCol * nBand : NAs produced by integer overflow
  1. 然后我尝试了第二个选项,即使用文件名 + 使用 file.path
  2. 读取的头文件
    headerfile <- file.path(dirname,"AISA_Flight_4_resampled")
    x <- read.ENVI(filename = filename,headerfile = headerfile)

我再次收到一条错误消息,内容为:

#Error in read.ENVI(filename = filename,headerfile = headerfile) :
#  read.ENVI: Could not open input header file: S:/LAB-cavender/4_Project_Folders/oakWilt/oak_wilt_image_analyses/R_input/6.15.2021 - Revisions/ENVI export/AISA/Resampled_flights/AISA_Flight_4_resampled
  1. 最后,我尝试了第三个选项,使用文件名 + 使用 readLines
  2. 读取的头文件
hdr_file <- readLines(con = "S:/LAB-cavender/4_Project_Folders/oakWilt/oak_wilt_image_analyses/R_input/6.15.2021 - Revisions/ENVI export/AISA/Resampled_flights/AISA_Flight_4_resampled.hdr")
x <- read.ENVI(filename = filename,headerfile = hdr_file)

但我收到错误消息:

#Error in read.ENVI(filename = filename,headerfile = hdr_file) :
#  read.ENVI: Could not open input header file: ENVIdescription = {  Spectrally Resampled File. Input number of bands: 63,output number of bands: 115. [Fri Jun 25 16:57:21 2021]}samples = 5187lines   = 6111bands   = 115header offset = 0file type = ENVI Standarddata type = 4interleave = bilsensor type = UnkNownbyte order = 0map info = {UTM,1.000,482828.358,5029367.353,7.5000000000e-001,15,north,WGS-84,units=Meters}coordinate system string = {PROJCS["UTM_Zone_15N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],ParaMETER["False_Easting",500000.0],ParaMETER["False_northing",ParaMETER["Central_Meridian",-93.0],ParaMETER["Scale_Factor",0.9996],ParaMETER["Latitude_Of_Origin",UNIT["Meter",1.0]]}default bands = {46,31,16}wavelength units = Nanometersdata ignore value = -9999.00000000e+000band names = { Resampled
#    In addition: Warning message:
#      In if (!file.exists(headerfile)) stop("read.ENVI: Could not open input header file: ",:
#                                              the condition has length > 1 and only the first element will be used

任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)