我在某种程度上搞砸了我的Macbook上的gdal安装。以前的代码工作在R
中打开和操作H4文件(.hdf)。并且相同的代码在我的桌面上工作。但是,现在,代码在我的桌面上运行,而不是我的笔记本电脑。相同的代码。相同的数据。在OSX/MAC上绑定GDAL与R - 无法打开/探索R中的h4文件
我怀疑这与试图通过conda
安装gdal
支持python
有关。
现在,如果我在bash的命令行上运行hdf文件中的gdalinfo
,它会读取文件。但是,如果我在R
运行此代码 - 使用GDALutils功能get_subdatasets():
get_subdatasets("MOD09GA.A2016199.h09v05.006.2016201065406.hdf")
它返回的错误:
ERROR 4: `data/week6/modis/reflectance/17_july_2016/MOD09GA.A2016199.h09v05.006.2016201065406.hdf' not recognised as a supported file format.
gdalinfo failed - unable to open 'data/week6/modis/reflectance/17_july_2016/MOD09GA.A2016199.h09v05.006.2016201065406.hdf'.
Error in split1[[1]] : subscript out of bounds
In addition: Warning message:
running command '"/usr/local/Cellar/gdal/1.11.5_3/bin/gdalinfo" "data/week6/modis/reflectance/17_july_2016/MOD09GA.A2016199.h09v05.006.2016201065406.hdf"' had status 1
```
同样使用另一个包 - rgdal我运行的功能,gdalinfo()
Warning message: running command '"/usr/local/Cellar/gdal/1.11.5_3/bin/gdalinfo" "data/week6/modis/reflectance/17_july_2016/MOD09GA.A2016199.h09v05.006.2016201065406.hdf"' had status 1
我意识到这些是两个不同的包和相关的功能。
我发现这个职位:
但代码gdal_chooseInstallation(hasDrivers=c("HDF4","HDF5"))
回报
Error in gdal_chooseInstallation(hasDrivers = c("HDF4", "HDF5")) : No installations match.
注:有趣的是这同我的桌面上的代码(即能够读取R中的文件)也会返回一个错误,即使它可以找到驱动程序)。
当然,我知道驱动程序存在于我的电脑上,因为我能够在R之外的命令行探索h4文件。而且我知道我的代码很好,因为它可以在我的桌面上使用相同的数据相同的目录结构。
任何想法如何我可以在我的Mac上清理我的gdal石板以消除潜在的冲突或将R引导至正确的gdal版本(但我不确定那是什么版本!)?这是与gdal绑定到R的具体关联,我不知道如何解决。
UPDATE: R中运行该:
system("gdalinfo --version")
返回:
GDAL 1.11.5, released 2016/07/01
然而在命令行
gdalinfo --version
返回
GDAL 2.1.0, released 2016/04/25
谢谢你的任何线索...... 利亚
更新: 我终于想通了如何对2链接和取消链接@中2,我已经想通了如何使用BREW在这一点上却安装HDF4,我不能重新安装gdal2
我使用此教程:
https://www.karambelkar.info/2016/10/gdal-2-on-mac-with-homebrew/
这昨天的工作,但后来我需要安装H4库我删除gdal2
brew remove gdal2
# install h4 libraries
brew install hdf4
,然后试图重新安装教程中的说明。
这里是我所得到的在这一点上
$ brew install gdal2 --with-armadillo --with-complete --with-libkml --with-unsupported
OUTPUT:
==> Installing gdal2 from osgeo/osgeo4mac
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
Warning: Use cfitsio instead of deprecated homebrew/science/cfitsio
==> Using Homebrew-provided fortran compiler.
This may be changed by setting the FC environment variable.
==> Downloading http://download.osgeo.org/gdal/2.2.1/gdal-2.2.1.tar.gz
Already downloaded: /Users/leah-su/Library/Caches/Homebrew/gdal2-2.2.1.tar.gz
==> ./configure --prefix=/usr/local/Cellar/gdal2/2.2.1 --mandir=/usr/local/Cella
Last 15 lines from /Users/leah-su/Library/Logs/Homebrew/gdal2/01.configure:
checking for SDget_maxopenfiles in -lmfhdf... yes
checking for H5Fopen in -lhdf5... yes
checking for kea-config... no
checking for kea... no
checking for nc-config... /usr/local/bin/nc-config
checking libnetcdf compiler and linker flags with nc-config...
got version="netCDF 4.4.1.1", prefix="/usr/local/Cellar/netcdf/4.4.1.1_6",
libs="-L/usr/local/Cellar/netcdf/4.4.1.1_6/lib -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz -ldl -lm -lcurl", includedir="/usr/local/Cellar/netcdf/4.4.1.1_6/include"
checking for nc_open in -lnetcdf... yes
checking for netcdf-4 (and HDF5) support in libnetcdf... yes
checking for HDF4 support in libnetcdf... no
configure: using JasPer library from /usr/local.
checking for jp2_encode_uuid in -ljasper... no
configure: hacked JasPer version not found, GeoJP2 disabled.
configure: error: openjpeg.h not found in /usr/local/include/openjpeg-2.0 or /usr/local/include/openjpeg-2.1
If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
https://github.com/osgeo/homebrew-osgeo4mac/issues
These open issues may also help:
brew install osgeo/osgeo4mac/gdal2-mrsid fails https://github.com/OSGeo/homebrew-osgeo4mac/issues/250
Failed to build gdal2 with common flags https://github.com/OSGeo/homebrew-osgeo4mac/issues/245
Cannot upgrade gdal2 on OS X 10.12.6 https://github.com/OSGeo/homebrew-osgeo4mac/issues/252
Please add --without-pdfium option to gdal2 formula https://github.com/OSGeo/homebrew-osgeo4mac/issues/220
Using osgeo4mac's gdal2 with homebrew core's postgis https://github.com/OSGeo/homebrew-osgeo4mac/issues/185
gdal1-mrsid and gdal2-mrsid fails to build https://github.com/OSGeo/homebrew-osgeo4mac/issues/213
```