Google Colab に geojsonio をインストールするには

インストールの install.packages("geojsonio") で次のように失敗しました。

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)

also installing the dependencies ‘proxy’, ‘e1071’, ‘wk’, ‘triebeard’, ‘classInt’, ‘Rcpp’, ‘s2’, ‘units’, ‘geometries’, ‘jsonify’, ‘rapidjsonr’, ‘sfheaders’, ‘urltools’, ‘httpcode’, ‘protolite’, ‘lazyeval’, ‘sp’, ‘sf’, ‘geojsonsf’, ‘rgeos’, ‘crul’, ‘maptools’, ‘V8’, ‘geojson’, ‘jqr’


Warning message in install.packages("geojsonio"):
“installation of package ‘units’ had non-zero exit status”
Warning message in install.packages("geojsonio"):
“installation of package ‘protolite’ had non-zero exit status”
Warning message in install.packages("geojsonio"):
“installation of package ‘jqr’ had non-zero exit status”
Warning message in install.packages("geojsonio"):
“installation of package ‘geojson’ had non-zero exit status”
Warning message in install.packages("geojsonio"):
“installation of package ‘sf’ had non-zero exit status”
Warning message in install.packages("geojsonio"):
“installation of package ‘geojsonio’ had non-zero exit status”

必要なパッケージを先にインストールする

依存パッケージが必要としているライブラリをインストールします。
sf、protolite、jqr パッケージが必要としているライブラリが Google Colab に無いようです。

# https://github.com/r-spatial/sf/issues/1572#issuecomment-758858154
system('sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable')
system('sudo apt-get update')
system('sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev')
# protolite
system('sudo apt-get install libprotobuf-dev protobuf-compiler')
# jqr
system('sudo apt-get install libjq-dev')

その後、install.packages("geojsonio") すれば、無事にインストールできました。

これで、sf で読み込んだデータを何かしたときに表示される ERROR while rich displaying an object: Error in loadNamespace(x): there is no package called ‘geojsonio’ が解消されました。

コメント