我们可以round
这些值
library(sp)
spg[1:2] <- lapply(spg[1:2],function(x) as.numeric(round(x)))
coordinates(spg) <- ~ lon + lat
gridded(spg) <- TRUE
-输出
> spg
Object of class SpatialPixelsDataFrame
Object of class SpatialPixels
Grid topology:
cellcentre.offset cellsize cells.dim
lon 9 69 2
lat 17 33 2
SpatialPoints:
lon lat
1 9 50
2 78 17
3 9 50
Coordinate Reference System (CRS) arguments: NA
Data summary:
temp
Min. :282.9
1st Qu.:288.1
Median :293.4
Mean :290.7
3rd Qu.:294.6
Max. :295.9
数据
df <- structure(list(lon = c(8.5261,78.439,8.635),lat = c(50.0223,17.229,49.929),temp = c(293.4,295.9,282.88)),class = "data.frame",row.names = c("1","2","3"))
本文链接:https://www.f2er.com/666.html