ここでは、分析のためにCT画像のtiffファイルをRにインポートしようとしています。私はループ上で分析しようとしている約250のtiffファイルを持っています。解析は、クロッピング、スレッシュホールド、ピクセル強度値に基づいてポロシティを計算することから始まります。現在、私はこのエラーを取得しています:ファイルがRラスタループに見つかりません
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file. (file does not exist)
`library(raster)
library(rgdal)
library(sp)`
`project_files <- dir("/Users/Rob/Documents/BMBT5130/Data")
for (jj in 1:length(mget(project_files))) {
x[jj] <- raster(paste0(project_files[jj]))
x1 <- crop(x, extent(800,1600,700,1600))
x[x<=35]=0
plot(x1)
Porosity[jj] <- (length(x1[x1<=35]))/length(x1[x1>=0])`
作業ディレクトリが
のSessionInfoの上に使用されるディレクトリです:
R version 3.3.3 (2017-03-06) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X El Capitan 10.11.6
locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] RBioFormats_0.0.30 rJava_0.9-8 EBImage_4.16.0 imager_0.40.2 magrittr_1.5 [6] plyr_1.8.4 ROI_0.2-1 rgdal_1.2-6 raster_2.5-8 sp_1.2-4 [11] tiff_0.1-5
loaded via a namespace (and not attached): [1] Rcpp_0.12.10 knitr_1.15.1 BiocGenerics_0.20.0 lattice_0.20-35 jpeg_0.1-8 [6] stringr_1.2.0 tools_3.3.3 parallel_3.3.3 grid_3.3.3 png_0.1-7 [11] registry_0.3 abind_1.4-5 bmp_0.2 purrr_0.2.2 fftwtools_0.9-8 [16] slam_0.1-40 readbitmap_0.1-4 stringi_1.1.5 locfit_1.5-9.1
この固定すべてのヘルプははるかに高く評価されます。すでにコメントで述べた
ベスト、
ロブ
'dir'を' list.files'に置き換えてみてください。 – www
ありがとうございます。エラーは 'File1.tif'が見つかりませんでした 'エラー:' – Rob
'list.files("/Users/Rob/Documents/BMBT5130/Data "、full.names = T、パターン= "tif $") ' – maRtin