I would think there should be a simple solution to this, but I can't figure it out.
I have a csv file with the following data
wealth_data <- read.csv(text ="latitude,longitude,rwi,error
-2.8223442,29.498291,-0.656,0.297
-2.8223442,29.5202637,-0.544,0.296
-2.8223442,29.5422363,-0.586,0.294
-2.800398,29.498291,-0.474,0.297
-2.800398,29.5202637,0.439,0.289
-2.7784514,29.498291,-0.068,0.289
-2.7784514,29.5202637,0.151,0.312
-2.7784514,29.5422363,0.696,0.331", stringsAsFactors=FALSE)
The entire dataset for rwanda can be downloaded here https://data.humdata.org/dataset/relative-wealth-index
And I can make it a sf dataframe
sf_wealth_data <- sf::st_as_sf(x = wealth_data,
coords = c("longitude", "latitude"),
crs = 4326)
now how do I make it into a terra raster object where the points of the sf are the center of the raster tiles, and the tiles take the value of just the one point at their center? The tiles without any points should have an NA
value.