0

I have two raster datasets. Dataset 1 is coarser (0.5 resolution) than dataset 2 (0.083 resolution). I need to harmonise them, and bring dataset 1 to dataset 2 (as dataset 1 is coarser). I need to do this using the disagg command, using the method "near".

The command I tried is:

harmonised_data <- disagg(dataset1, dataset2, method="near", filename="merged_data"). I get the following error:
# Error: not compatible with requested type: [type=s4, target=double].

If someone has a solution, would be great, thank you!

Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63
Anjana
  • 1
  • 1
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jul 10 '23 at 15:34
  • I don't have any examples of the desired output and I am unfortunately not able to provide sample data because it is currently confidential, sorry! – Anjana Jul 10 '23 at 15:44
  • Sample data does not mean *your data*. It means any little datasets that can be used to run the code. See e.g., all the R help files, such as `?terra::disagg` – Robert Hijmans Jul 10 '23 at 23:38

1 Answers1

0

The documentation for disagg shows

?disagg

## S4 method for signature 'SpatRaster'
disagg(x, fact, method="near", filename="", ...)

where x is a "SpatRaster" and fact is a "positive integer". You are using a "SpatRaster" for argument fact. Hence the error.

What you can do is something like this

0.5 / 0.08333333
[1] 6

h <- disagg(dataset1, 6)

You could also do

r <- resample(dataset1, dataset2)
Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63