RGEE on Ubuntu with your Conda environment

  1. Create a Google Earth Engine account: get to the place of where you can login to the coding console. If you use the package to help you get setup with an account, it will not take you through the final step(s). I went through this process while creating a new account, and though there is currently a bug with authentication, this was causing me more headaches than I was realizing.
  2. Setup a conda environment (I used miniconda):
    • create and activate your environment
    • install python
    • conda install numpy
    • conda install earthengine-api==0.1.370
  3. Install the following dependencies if you don’t already have them. You also might run into a bear of a problem with protobuf, protoc, libprotoc etc. If so, activate your conda environment and roll back protobuf to pip install protobuf==3.20.3
    • gdal-bin
    • libgdal-dev
    • libudunits2-dev
  4. Edit your ~/.Renviron file to include the following (or create it if it doesn’t exist):
    RETICULATE_PYTHON="path to your conda env python install" RETICULATE_PYTHON_ENV="path to your conda env"
  5. Install reticulate R package
  6. Install rgee R package
    • use install_ee_set_pyenv() with your environment settings as above
    • ee_Authenticate()

This should get you to the point of having rgee run off your own custom Python environment, with the downgraded version of the Earth Engine API required to authenticate at the time of this writing. A workaround for the bug in initializing GEE is starting your script as follows (bypassing ee_Initialize()):
ee$Initialize(project='your project name')

You will also have .Renviron entries for Earth Engine now. This final step is one I’m unsure of: if you haven’t manually created a legacy asset folder, you may from here be able to run ee_Initialize() and create one. I had created one, and so I got caught in a loop of it saying it already existed while wanting me to create one. So, in short, I’ve never really been able to successfully run ee_Initialize() and the package author is at a point of not even wanting to maintain it anymore. The problem here is that you don’t get this file generated: .config/earthengine/rgee_sessioninfo.txt

So, you can make your own structured as so:

“user” “drive_cre” “gcs_cre”

The path to your credential file is the one you created to authenticate earth engine, somewhere in that folder. (Save a copy elsewhere to to move back into that path, because I’m not sure the file persists between sessions.)