I realize that the title of this question is similar to another question, but the solution there does not work for me.
I have a raster file. I have a matrix of latitudes and a matrix of longitudes. I want to replace the x and y coordinates of the raster file with those in the two matrices.
I have uploaded example files here. There are three files, one if a raster (GeoTIFF) and two matrices of longitudes and latitudes.
## read in the raster
raster <- raster("test.tif")
## Read in the coordinates
lat1 <- read.csv("lat1.csv")
lon1 <- read.csv("lon1.csv")
raster$lon <- lon1 ##??? no clue
raster$lat <- lat1 ##???
https://www.dropbox.com/sh/0lsdgo3mk95hua8/AAA9fMuCo2XZmu50U6QFq4cEa?dl=0
What is an easy way to do this? Can I use the same methods on a RasterBrick?
I have tried many things, I cannot find how to replace the coordinates.
Any help would be appreciated.