I have that geoid heights (quasi-geoid model hBG18) in a form that matrix :
library(tidyverse)
Geo <- read.table("https://www.isgeoid.polimi.it/Geoid/Europe/Belgium/public/hBG18.dat",
header=FALSE)
Geo <- Geo %>% rename("x" = "V2", "y" = "V1","z" = "V3")
And I would like to extract that heights for the given locations:
newdata <- structure(list(x = c(5.6029075, 5.60290583333333, 5.60290283333333,
5.60289525, 5.60289583333333, 5.60289016666667), y = c(49.7203561666667,
49.7203568333333, 49.7203568333333, 49.7203585, 49.7203595, 49.7203593333333
)), row.names = c(NA, 6L), class = "data.frame")
I have tried to use interp.surface()
from the package 'fields' but it does not work.
newdata$z <- fields::interp.surface(Geoide, newdata)
Error in xy.coords(x, y, setLab = FALSE) : 'x' and 'y' lengths differ
I was wondering how could I proceed to obtain that Z value.
I have also tried to do an interpolation of the Geoid heights with interp()
form the package "akima", to after extract the Z value. But the code does not work either...
EDIT
Geoide
? Have you tried to convert the dataframe from the file to a list as described in the documentation forinterp.surface
? If that's gone wrong then that could be the reason for the error. Edit the Q to show how you madeGeoide
.