{"id":16272870,"url":"https://github.com/robitalec/targets-rgee-extract","last_synced_at":"2026-07-05T17:31:16.948Z","repository":{"id":62953143,"uuid":"563181899","full_name":"robitalec/targets-rgee-extract","owner":"robitalec","description":":hammer_and_wrench: Example repository for extracting covariates (= sampling images) using rgee from sample points (eg. animal movement data) with a targets workflow","archived":false,"fork":false,"pushed_at":"2023-02-27T13:53:30.000Z","size":1210,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T15:52:30.714Z","etag":null,"topics":["earth-engine","earthengine","r","rgee","targets"],"latest_commit_sha":null,"homepage":"https://robitalec.github.io/targets-rgee-extract/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robitalec.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-08T04:20:10.000Z","updated_at":"2022-12-06T15:32:44.000Z","dependencies_parsed_at":"2024-06-11T16:59:10.200Z","dependency_job_id":"040fedd7-b02b-4aa4-847a-48e63c3a3b07","html_url":"https://github.com/robitalec/targets-rgee-extract","commit_stats":null,"previous_names":[],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/robitalec/targets-rgee-extract","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robitalec%2Ftargets-rgee-extract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robitalec%2Ftargets-rgee-extract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robitalec%2Ftargets-rgee-extract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robitalec%2Ftargets-rgee-extract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robitalec","download_url":"https://codeload.github.com/robitalec/targets-rgee-extract/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robitalec%2Ftargets-rgee-extract/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260221365,"owners_count":22976863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["earth-engine","earthengine","r","rgee","targets"],"created_at":"2024-10-10T18:20:05.024Z","updated_at":"2025-10-28T12:10:09.576Z","avatar_url":"https://github.com/robitalec.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: 'targets-rgee-extract'\noutput: \n  github_document:\n    toc: true\n---\n\n\n```{r include=FALSE}\nknitr::opts_chunk$set(\n\tfig.path = \"man/figures/\"\n)\n\nlibrary(targets)\nlibrary(sf)\n```\n\n## Goal\n\nLearning Earth Engine (though I highly recommend it), can be a bit of overhead\nif you just need to, for example, sample a land cover product for a \ncollection of points. Great packages like `sf` and `terra` exist in the \nR ecosystem for sampling from rasters, but Earth Engine (and its user community) \noffers an incredible resource of data sets (see below) that can be accessed\nwithout downloading any large files to your local machine. \nWith that in mind, this project combines `targets` and\n`rgee` with a couple simple helper functions, to make simple operations\nwith Earth Engine easier. We won't cover anywhere near the full potential\nof Earth Engine, just things like sampling images or image collections with\ndifferent types of features (for now). \n\nWorking with Earth Engine through the Python package (or through `rgee` which\nalso goes through the Python package via `reticulate`) has one main challenge \ncompared to the JavaScript API for Earth Engine: setup. See below for steps that\nworked for me. You'll first need to install system dependencies, \nthen install some R packages and authenticate with Earth Engine. \n`renv` is used to track required R and Python packages. \n\nOpen an issue, submit a PR, or otherwise get in touch if you have any\nthoughts or would like to contribute. Thanks!\n\n\n## Usage\n\nThis repository is a [template repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template), so you can select \"Use this template\"\nto start a new project quickly with the setup and example targets workflow.\n\n![](https://docs.github.com/assets/cb-100333/images/help/repository/use-this-template-button.png)\n\nThen see the [Setup](#setup) section below for installing system and R \ndependencies. \n\n\n\n## Neat data sets\n\nTODO\n\n- https://developers.google.com/earth-engine/datasets/\n- https://samapriya.github.io/awesome-gee-community-datasets/\n\n\n## Outputs\n### Sample image with polygons\n\nFor example, extract the maximum elevation in each polygon (\"elevation\"):\n\n```{r}\ntar_load(sample_image_with_polys)\nhead(sample_image_with_polys)\nplot(sample_image_with_polys)\n```\n\n\n\n### Sample image with points\n\nFor example, extract the leading tree species at each point (\"b1\"):\n\n```{r}\ntar_load(sample_image_with_points)\nhead(sample_image_with_points)\nplot(sample_image_with_points['b1'])\n```\n\n\n\n### Sample image collections with polygons\n\nFor example, extract the monthly water detection within polygons (2 = water, 1 = land)\n\n```{r}\ntar_load(sample_image_collection_with_polygons)\nhead(sample_image_collection_with_polygons)\nplot(sample_image_collection_with_polygons)\n```\n\n\n\n### Sample image collections with points\n\nFor example, Landsat 8 bands at each point: \n\n```{r}\ntar_load(sample_image_collection_with_points)\nhead(sample_image_collection_with_points)\nplot(sample_image_collection_with_points)\n```\n\nNote - these are spread wide, where each measure is a new column. That\nmeans they will likely need to be restructured for further processing. \n\n\n\n## Setup\n\nSystem dependencies:\n\n- gcloud (https://cloud.google.com/sdk/docs/install)\n- python \u003e= 3.5\n- earthengine python package\n\n\nFirst time using this project:\n\n```{r, eval = FALSE}\nSys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)\ninstall.packages('renv')\nrenv::restore()\nrgee::ee_Authenticate()\nrgee::ee_Initialize(drive = TRUE)\n```\n\n\n\n### Dependencies\n\nSystem dependencies above. \n\nDetails for `rgee` here: https://r-spatial.github.io/rgee/articles/rgee01.html#installation\n\n\n\n#### `rgee` \n\nThe \"first time\" section above should get you set up, but if you are starting from scratch: \n\n\nInstall:\n\n```{r, eval = FALSE}\nlibrary(rgee)\nee_install(py_env = 'rgee')\n```\n\n\nAuthenticate:\n\n```{r, eval = FALSE}\nee_Initialize()\n```\n\n\nCheck:\n\n```{r, eval = FALSE}\nee_check()\n```\n\n\nRenv + python:\n\n```{r, eval = FALSE}\nrenv::use_python(reticulate::py_discover_config()$python)\nrenv::snapshot()\n```\n\n\n## Resources\n\n- `rgee`\n\t- https://csaybar.github.io/rgee-examples/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobitalec%2Ftargets-rgee-extract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobitalec%2Ftargets-rgee-extract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobitalec%2Ftargets-rgee-extract/lists"}