1

我是在 R 中使用 GIS 的新手,我正在尝试按照这篇文章R 如何读取 ENVI .hdr 文件的建议打开一个包含高光谱数据的 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读取的头文件名
    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读取的头文件名
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, 1.000, 482828.358, 5029367.353, 7.5000000000e-001, 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",0.0],PARAMETER["Central_Meridian",-93.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],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

任何帮助将非常感激!

4

0 回答 0