Skip to content

[help] How to use geodata package with targets #1238

Closed Answered by Aariq
njtierney asked this question in Help
Discussion options

You must be logged in to vote

Since it looks like crop_spam() returns a SpatRaster object, the discussion here might be useful. In particular, I've been using the following for the format argument for targets that return SpatRasters with success.

format_geotiff <- 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)
)

list(
tar_target(coffee_data, crop_coffee_data(), format = format_geotiff)
)

The other option is to write the results out explicitly as part of your crop_coffee_data() function (e.g…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@njtierney
Comment options

Answer selected by njtierney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants