{"id":26353267,"url":"https://github.com/ropensci/geotargets","last_synced_at":"2025-04-09T11:10:00.845Z","repository":{"id":225730010,"uuid":"766688189","full_name":"ropensci/geotargets","owner":"ropensci","description":"Targets extensions for geospatial data","archived":false,"fork":false,"pushed_at":"2025-03-21T01:10:40.000Z","size":3850,"stargazers_count":74,"open_issues_count":26,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T17:47:27.061Z","etag":null,"topics":["geospatial","pipeline","r","r-package","r-targetopia","raster","reproducibility","reproducible-research","rstats","targets","vector","workflow"],"latest_commit_sha":null,"homepage":"https://ropensci.github.io/geotargets/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ropensci.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json"}},"created_at":"2024-03-03T23:24:01.000Z","updated_at":"2025-03-27T21:16:57.000Z","dependencies_parsed_at":"2024-03-04T01:25:32.931Z","dependency_job_id":"7dd775d1-41fe-430f-a38c-e73d0ad870c6","html_url":"https://github.com/ropensci/geotargets","commit_stats":{"total_commits":179,"total_committers":4,"mean_commits":44.75,"dds":0.5307262569832403,"last_synced_commit":"2753efe5fb608f510f1893b5480ed826a2d31902"},"previous_names":["njtierney/geotargets","ropensci/geotargets"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2Fgeotargets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2Fgeotargets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2Fgeotargets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2Fgeotargets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ropensci","download_url":"https://codeload.github.com/ropensci/geotargets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027408,"owners_count":21035594,"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":["geospatial","pipeline","r","r-package","r-targetopia","raster","reproducibility","reproducible-research","rstats","targets","vector","workflow"],"created_at":"2025-03-16T11:08:58.497Z","updated_at":"2025-04-09T11:10:00.821Z","avatar_url":"https://github.com/ropensci.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# geotargets \u003ca href=\"https://docs.ropensci.org/geotargets/\"\u003e\u003cimg src=\"man/figures/logo.png\" alt=\"geotargets website\" align=\"right\" height=\"139\"/\u003e\u003c/a\u003e \n\n\u003c!-- badges: start --\u003e\n[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![R Targetopia](https://img.shields.io/badge/R_Targetopia-member-blue?style=flat\u0026labelColor=gray)](https://wlandau.github.io/targetopia/)\n[![R-CMD-check](https://github.com/ropensci/geotargets/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ropensci/geotargets/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/ropensci/geotargets/branch/master/graph/badge.svg)](https://app.codecov.io/gh/ropensci/geotargets?branch=master)\n[![pkgcheck](https://github.com/ropensci/geotargets/workflows/pkgcheck/badge.svg)](https://github.com/ropensci/geotargets/actions?query=workflow%3Apkgcheck)\n[![Status at rOpenSci Software Peer Review](https://badges.ropensci.org/675_status.svg)](https://github.com/ropensci/software-review/issues/675)\n\u003c!-- badges: end --\u003e\n\n`geotargets` extends [`targets`](https://github.com/ropensci/targets) to work with geospatial data formats, such as rasters and vectors (e.g., shapefiles). Currently we support raster and vector formats for the [`terra`](https://github.com/rspatial/terra) package. \n\nIf you are unfamiliar with targets, we recommend watching [\"targets in 4 minutes\"](https://docs.ropensci.org/targets/#get-started-in-4-minutes).\n\n## How to cite geotargets\n\nOne example citation of geotargets could be as follows: \"R packages used in this analysis included (list R packages used), targets, and geotargets (Tierney, N., Scott, E., \u0026 Brown, A, 2024). Here is the full bibliographic reference for your references:\n\n\u003e Tierney N, Scott E, Brown A\n  (2024). \"geotargets: 'Targets'\n  Extensions for Geospatial\n  Formats.\"\n  \u003chttps://docs.ropensci.org/geotargets/\u003e.\n\n## Installation\n\nYou can install the development version of geotargets like so:\n\n``` r\ninstall.packages(\"geotargets\", repos = c(\"https://ropensci.r-universe.dev\", \"https://cran.r-project.org\"))\n```\n\n## Why `geotargets`\n\nIf you want to use geospatial data formats (such as `terra`) with the [`targets`](https://github.com/ropensci/targets) package to build analytic reproducible pipelines, it involves writing a lot of custom targets wrappers. We wrote `geotargets` so you can use geospatial data formats with `targets`.\n\nTo provide more detail on this, a common problem when using popular libraries like `terra` with `targets` is running into errors with read and write. Due to the limitations that come with the underlying C++ implementation in the `terra` library, there are specific ways to write and read these objects. See `?terra` for details. `geotargets` helps handle these write and read steps, so you don't have to worry about them and can use targets as you are used to.\n\nIn essence, if you've ever come across the error:\n\n```\nError in .External(list(name = \"CppMethod__invoke_notvoid\", address = \u003cpointer: 0x0\u003e,  : \n  NULL value passed as symbol address\n```\n\nor \n\n```\nError: external pointer is not valid\n```\n\nWhen trying to read in a geospatial raster or vector in targets, then `geotargets` for you :)\n\n# Examples\n\nWe currently provide support for the `terra` package with `targets`. Below we show three examples of target factories:\n\n- `tar_terra_rast()`\n- `tar_terra_vect()`\n- `tar_terra_sprc()`\n- `tar_terra_sds()`\n- `tar_tera_tiles()`\n- `tar_stars()`\n\nYou would use these in place of `tar_target()` in your targets pipeline, e.g., when you are doing work with `terra` raster, vector, or raster collection data.\n\nIf you would like to see and download working examples for yourself, see the repos: \n\n- [demo-geotargets](https://github.com/njtierney/demo-geotargets)\n- [icebreaker](https://github.com/njtierney/icebreaker)\n\n## `tar_terra_rast()`: targets with terra rasters\n\n```{r}\n#| label: tar-terra-rast\nlibrary(targets)\n\ntar_dir({ # tar_dir() runs code from a temporary directory.\n  tar_script({\n    library(geotargets)\n\n    get_elev \u003c- function() {\n      terra::rast(system.file(\"ex\", \"elev.tif\", package = \"terra\"))\n    }\n\n    list(\n      tar_terra_rast(\n        terra_rast_example,\n        get_elev()\n      )\n    )\n  })\n\n  tar_make()\n  x \u003c- tar_read(terra_rast_example)\n  x\n})\n```\n\n\n## `tar_terra_vect()`: targets with terra vectors\n\n```{r}\n#| label: tar-terra-vect\ntar_dir({ # tar_dir() runs code from a temporary directory.\n  tar_script({\n    library(geotargets)\n\n    lux_area \u003c- function(projection = \"EPSG:4326\") {\n      terra::project(\n        terra::vect(system.file(\"ex\", \"lux.shp\",\n          package = \"terra\"\n        )),\n        projection\n      )\n    }\n\n    list(\n      tar_terra_vect(\n        terra_vect_example,\n        lux_area()\n      )\n    )\n  })\n\n  tar_make()\n  x \u003c- tar_read(terra_vect_example)\n  x\n})\n```\n\n\n## `tar_terra_sprc()`: targets with terra raster collections\n\n```{r}\n#| label: tar-terra-sprc\ntar_dir({ # tar_dir() runs code from a temporary directory.\n  tar_script({\n    library(geotargets)\n\n    elev_scale \u003c- function(z = 1, projection = \"EPSG:4326\") {\n      terra::project(\n        terra::rast(system.file(\"ex\", \"elev.tif\", package = \"terra\")) * z,\n        projection\n      )\n    }\n\n    list(\n      tar_terra_sprc(\n        raster_elevs,\n        # two rasters, one unaltered, one scaled by factor of 2 and\n        # reprojected to interrupted goode homolosine\n        command = terra::sprc(list(\n          elev_scale(1),\n          elev_scale(2, \"+proj=igh\")\n        ))\n      )\n    )\n  })\n\n  tar_make()\n  x \u003c- tar_read(raster_elevs)\n  x\n})\n```\n\n\n\n## `tar_stars()`: targets with stars objects\n\n```{r}\n#| label: tar-stars\ntar_dir({ # tar_dir() runs code from a temporary directory.\n  tar_script({\n    library(geotargets)\n\n    list(\n      tar_stars(\n        test_stars,\n        stars::read_stars(system.file(\"tif\", \"olinda_dem_utm25s.tif\", package = \"stars\"))\n      )\n    )\n  })\n\n  tar_make()\n  x \u003c- tar_read(test_stars)\n  x\n})\n```\n\n\n## Code of Conduct\n\nPlease note that the geotargets project is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.\n\n## Acknowledgements\n\nLogo design by Hubert Hałun at Appsilon.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fropensci%2Fgeotargets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fropensci%2Fgeotargets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fropensci%2Fgeotargets/lists"}