-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 52670f0
Showing
24 changed files
with
521 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
^geotargets\.Rproj$ | ||
^\.Rproj\.user$ | ||
^README\.Rmd$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.Rdata | ||
.httr-oauth | ||
.DS_Store | ||
.quarto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Package: geotargets | ||
Title: Targets extensions for geospatial | ||
Version: 0.0.0.9000 | ||
Authors@R: c( | ||
person( | ||
given = "Nicholas", | ||
last = "Tierney", | ||
email = "nicholas.tierney@gmail.com", | ||
role = c("aut", "cre"), | ||
comment = c(ORCID = "https://orcid.org/0000-0003-1460-8722") | ||
), | ||
person( | ||
given = "", | ||
last = "", | ||
email = "", | ||
role = c("aut"), | ||
comment = c(ORCID = "https://orcid.org/XXXX") | ||
) | ||
) | ||
Description: Provides extensions for various geospatial file formats, | ||
including shapefiles, rasters, and more. See the vignettes for worked | ||
examples and demonstrations and explanations of how to use the various | ||
package extensions | ||
License: MIT + file LICENSE | ||
Encoding: UTF-8 | ||
Language: en-GB | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.1 | ||
Imports: | ||
targets, | ||
terra, | ||
utils | ||
Suggests: | ||
testthat (>= 3.0.0) | ||
Config/testthat/edition: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#' @keywords internal | ||
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
#' @import rlang | ||
#' @importFrom glue glue | ||
#' @importFrom lifecycle deprecated | ||
## usethis namespace: end | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
tar_geotiff <- function(name, | ||
command, | ||
pattern = NULL, | ||
tidy_eval = targets::tar_option("tidy_eval"), | ||
library = targets::tar_option_get("library"), | ||
repository = targets::tar_option_get("repository"), | ||
iteration = targets::tar_option_get("iteration"), | ||
error = targets::tar_option_get("error"), | ||
memory = targets::tar_option_get("memory"), | ||
garbage_collection = targets::tar_option_get("garbage_collection"), | ||
deployment = targets::tar_option_get("deployment"), | ||
priority = targets::tar_option_get("priority"), | ||
resources = targets::tar_option_get("resources"), | ||
storage = targets::tar_option_get("storage"), | ||
retrieval = targets::tar_option_get("retrieval"), | ||
cue = targets::tar_option_get("cue")) { | ||
name <- targets::tar_deparse_language(substitute(name)) | ||
|
||
envir <- tar_option_get("envir") | ||
|
||
command <- targets::tar_tidy_eval( | ||
expr = as.expression(substitute(command)), | ||
envir = envir, | ||
tidy_eval = tidy_eval | ||
) | ||
pattern <- targets::tar_tidy_eval( | ||
expr = as.expression(substitute(pattern)), | ||
envir = envir, | ||
tidy_eval = tidy_eval | ||
) | ||
|
||
format_geotiff <- targets::tar_format( | ||
read = function(path) terra::rast(path), | ||
write = function(object, path) { | ||
terra::writeRaster( | ||
x = object, | ||
filename = path, | ||
filetype = "GTiff", | ||
overwrite = TRUE | ||
) | ||
}, | ||
marshal = function(object) terra::wrap(object), | ||
unmarshal = function(object) terra::unwrap(object) | ||
) | ||
|
||
targets::tar_target_raw( | ||
name = name, | ||
command = command, | ||
pattern = pattern, | ||
packages = packages, | ||
library = library, | ||
format = format_geotiff, | ||
repository = repository, | ||
iteration = iteration, | ||
error = error, | ||
memory = memory, | ||
garbage_collection = garbage_collection, | ||
deployment = deployment, | ||
priority = priority, | ||
resources = resources, | ||
storage = storage, | ||
retrieval = retrieval, | ||
cue = cue | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
format_shapefile <- targets::tar_format( | ||
read = function(path) { | ||
terra::vect( | ||
paste0( | ||
"/vsizip/", | ||
file.path( | ||
path, | ||
replace_dot_zip_with_shp(path) | ||
) | ||
) | ||
) | ||
}, | ||
write = function(object, path) { | ||
terra::writeVector( | ||
x = object, | ||
filename = replace_dot_zip_with_shp(path), | ||
filetype = "ESRI Shapefile", | ||
overwrite = TRUE | ||
) | ||
zf <- list.files( | ||
pattern = replace_dot_zip( | ||
x = path, | ||
replacement = "" | ||
) | ||
) | ||
utils::zip( | ||
zipfile = path, | ||
files = zf | ||
) | ||
unlink(zf) | ||
}, | ||
marshal = function(object) terra::wrap(object), | ||
unmarshal = function(object) terra::unwrap(object) | ||
) | ||
|
||
tar_shapefile <- function(name, | ||
command, | ||
pattern = NULL, | ||
tidy_eval = targets::tar_option("tidy_eval"), | ||
library = targets::tar_option_get("library"), | ||
repository = targets::tar_option_get("repository"), | ||
iteration = targets::tar_option_get("iteration"), | ||
error = targets::tar_option_get("error"), | ||
memory = targets::tar_option_get("memory"), | ||
garbage_collection = targets::tar_option_get("garbage_collection"), | ||
deployment = targets::tar_option_get("deployment"), | ||
priority = targets::tar_option_get("priority"), | ||
resources = targets::tar_option_get("resources"), | ||
storage = targets::tar_option_get("storage"), | ||
retrieval = targets::tar_option_get("retrieval"), | ||
cue = targets::tar_option_get("cue")) { | ||
name <- targets::tar_deparse_language(substitute(name)) | ||
|
||
envir <- tar_option_get("envir") | ||
|
||
command <- targets::tar_tidy_eval( | ||
expr = as.expression(substitute(command)), | ||
envir = envir, | ||
tidy_eval = tidy_eval | ||
) | ||
pattern <- targets::tar_tidy_eval( | ||
expr = as.expression(substitute(pattern)), | ||
envir = envir, | ||
tidy_eval = tidy_eval | ||
) | ||
|
||
targets::tar_target_raw( | ||
name = name, | ||
command = command, | ||
pattern = pattern, | ||
packages = packages, | ||
library = library, | ||
format = format_shapefile, | ||
repository = repository, | ||
iteration = iteration, | ||
error = error, | ||
memory = memory, | ||
garbage_collection = garbage_collection, | ||
deployment = deployment, | ||
priority = priority, | ||
resources = resources, | ||
storage = storage, | ||
retrieval = retrieval, | ||
cue = cue | ||
) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
replace_dot_zip <- function(x, replacement){ | ||
gsub( | ||
pattern = "\\.zip", | ||
replacement = replacement, | ||
x = basename(x) | ||
) | ||
} | ||
|
||
replace_dot_zip_with_shp <- function(x){ | ||
replace_dot_zip(x, ".shp") | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
fig.path = "man/figures/README-", | ||
out.width = "100%" | ||
) | ||
``` | ||
|
||
# geotargets | ||
|
||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
The goal of geotargets is to extend targets to work with geospatial data, like shapefiles and rasters. | ||
|
||
## Installation | ||
|
||
You can install the development version of geotargets like so: | ||
|
||
``` r | ||
remotes::install_github("njtierney/geotargets") | ||
``` | ||
|
||
## Package still under development | ||
|
||
Currently geotargets provides: | ||
|
||
- `tar_geotiff` | ||
- `tar_shapefile` | ||
|
||
But these are under development. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
# geotargets | ||
|
||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
The goal of geotargets is to extend targets to work with geospatial | ||
data, like shapefiles and rasters. | ||
|
||
## Installation | ||
|
||
You can install the development version of geotargets like so: | ||
|
||
``` r | ||
remotes::install_github("njtierney/geotargets") | ||
``` | ||
|
||
## Package still under development | ||
|
||
Currently geotargets provides: | ||
|
||
- `tar_geotiff` | ||
- `tar_shapefile` | ||
|
||
But these are under development. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: No | ||
SaveWorkspace: No | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 4 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: knitr | ||
LaTeX: pdfLaTeX | ||
|
||
AutoAppendNewline: Yes | ||
StripTrailingWhitespace: Yes | ||
LineEndingConversion: Posix | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source | ||
PackageRoxygenize: rd,collate,namespace |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.