Я попытался установить пакет sf
, потому что он зависит от пакета tidycensus
, который я хотел бы использовать.
Я использую Mac с Big Sur. Согласно Github для r-spatial, я пытался следовать инструкциям по установке здесь, но без кубиков. Мой sessionInfo()
:
R version 4.1.0 (2021-05-18)
Platform: aarch64-apple-darwin20.4.0 (64-bit)
Running under: macOS Big Sur 11.6
Matrix products: default
BLAS: /opt/homebrew/Cellar/openblas/0.3.20/lib/libopenblasp-r0.3.20.dylib
LAPACK: /opt/homebrew/Cellar/r/4.1.0/lib/R/lib/libRlapack.dylib
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
loaded via a namespace (and not attached):
[1] compiler_4.1.0
Я попытался
library(devtools)
install_github("r-spatial/sf",configure.args = "--with-proj-lib=/opt/homebrew/opt/proj/lib")
Ошибка:
Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘sf’ ...
** using staged installation
configure: CC: /opt/homebrew/opt/llvm/bin/clang
configure: CXX: /opt/homebrew/opt/llvm/bin/clang++ -std=gnu++11
checking for gdal-config... /opt/homebrew/Caskroom/miniforge/base/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.4.1
checking GDAL version >= 2.0.1... yes
checking for gcc... /opt/homebrew/opt/llvm/bin/clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /opt/homebrew/opt/llvm/bin/clang accepts -g... yes
checking for /opt/homebrew/opt/llvm/bin/clang option to accept ISO C89... none needed
checking how to run the C preprocessor... /opt/homebrew/opt/llvm/bin/clang -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /opt/homebrew/Caskroom/miniforge/base/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... dyld: Library not loaded: @rpath/libgdal.30.dylib
Referenced from: /private/var/folders/4b/2jtbyjzd1w5gsdm_g_jcpr2h0000gn/T/Rtmp2cQwgC/R.INSTALL5d284632664c/sf/./gdal_proj
Reason: image not found
./configure: line 3625: 24751 Abort trap: 6 ./gdal_proj
no
configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?
ERROR: configuration failed for package ‘sf’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/sf’
Что-то, что может меня сбить с толку (но я не знаю, как это исправить), заключается в том, что gdal-config находится как в /opt/homebrew/Caskroom/miniforge/base/bin/
, так и в /opt/homebrew/opt/gdal/bin/
.
gdal
, proj
и geos
все живут в /opt/homebrew/opt/
Возможно, следование инструкциям по установке gdal и geos без варки может решить проблему: github.com/r-spatial/sf/issues/1536#issuecomment-727606409
Я пытался построить libgdal
и libproj
, но столкнулся с некоторыми ошибками. Я могу попробовать безварную стратегию
Почему бы не установить бинарную версию, как это предлагается в документации по sf? Я использую R 4.1.2 в Big Sur, и бинарная установка sf прошла успешно, а затем install.packages("tidycensus", dependencies=TRUE)
также удалось. В качестве дополнительных зависимостей были установлены пакеты rgdal, tigris и srvyr.
Решение, благодаря @IRTFM, заключалось в том, чтобы загрузить двоичный файл из CRAN, а затем использовать R CMD INSTALL
. Тогда я мог бы установить tigris
и tidycensus
через install.packages()
Возможно, стоит проверить здесь: github.com/r-spatial/sf/issues/1542 Одним из решений было создание
libgdal
иlibproj
из исходного кода.