In order to interpolate prices with kriging you first need to convert your geographic coordinates to projected coordinates. Assuming you have them, below there is a reproducible example, showing a way to accomplish such task.
#Spatial data containing variables which can be interpolated.
#We will use the zinc column; as an equivalent for 'price'.
data(meuse) #data.frame with geometries (projected coordinates)
coordinates(meuse) = ~x+y #Convert data.frame object in SpatialPointsDataFrame object
head(meuse[,c(4)],3) #Show first three lines, with projected coordinates and zinc values.
(181072, 333611) 1022
(181025, 333558) 1141
(181165, 333537) 640
#This will be the prediction grid, i.e., where the interpolated values will be printed.
gridded(meuse.grid) = ~x+y #Convert data.frame object to SpatialPixelsDataFrame object.
plot(meuse.grid) #this is the 'raster'(grid) you said, you'd need.
Now, we will use the function
autoKrige to perform an ordinary kriging using zinc values from the meuse dataset, and print the interpolation result to the prediction grid ('meuse.grid').
#Perform ordinary kriging and store results inside object of type "autoKrige" "list"
kriging_result = autoKrige(zinc~1, meuse, meuse.grid)
Here you go:
But now, let's suppose you don't have the prediction grid already available as we had with the 'meuse.grid' data. So, here is one example showing how to build the prediction grid:
#Setting the prediction grid properties
min_x = min(meuse$x) #minimun x coordinate
min_y = min(meuse$y) #minimun y coordinate
x_length = max(meuse$x - min_x) #easting amplitude
y_length = max(meuse$y - min_y) #northing amplitude
cellsize = 100 #pixel size
ncol = round(x_length/cellsize,0) #number of columns in grid
nrow = round(y_length/cellsize,0) #number of rows in grid
coordinates(meuse) = ~x+y
proj4string(meuse) = CRS("+proj=utm +ellps=WGS84 +datum=WGS84") #assign CRS with projected coordinates.
grid = GridTopology(cellcentre.offset=c(min_x,min_y),cellsize=c(cellsize,cellsize),cells.dim=c(ncol,nrow))
#Convert GridTopolgy object to SpatialPixelsDataFrame object.
grid = SpatialPixelsDataFrame(grid,
And then, repeat the steps of the ordinary kriging with the
autoKrige function. In this case, the interpolation will be performed in the whole graticulate, but the correct thing to do would be to perform the ordinary kriging only within the extents where the data is available. So, the below code shows an example (not reproducible, though) about using a shapefile to clip the extents of the prediction grid.
#Read shapefile and convert it to SpatialPolygons object.
#In the case of OP, the shapefile should be the administrative boundary of Germany.
shp = readOGR(dsn = "...", layer = "shp")
shp = shp@polygons
shp = SpatialPolygons(shp, proj4string=CRS("+proj=utm +ellps=WGS84 +datum=WGS84")) #make sure the shapefile has the same CRS from the data, and from the prediction grid.
#Clip the prediction grid with the shapefile.
grid = grid[!is.na(over(grid, shp)),]
If I had the shapefile with the boundaries of the 'meuse' dataset,
this command would produce a grid equal to the command
plot(meuse.grid). This post, illustrates how the clipping works.