converting dataframe to spatialpixelsdataframe

,

I'm trying make spatialpixelsdataframe form dataframe but keep getting same error " Error in getGridIndex(coordinates(points), grid) : this.idx out of range "

my data(FHM) has 37 variable excludding two FIDs Field1, point, N, E, num, and dotal 530 data
FHM
FID FID_ Field1 point N E num pH OM bio01
1 0 0 3 1283681 367695.50 127934.2 318 4.3 4.43 12.7852
2 1 1 4 1401081 107688.69 139922.0 67 4.6 4.91 14.4131
3 2 2 5 1484761 475696.66 147932.2 359 5.1 1.45 12.2260
4 3 3 6 1521561 155698.18 151925.6 73 4.7 2.51 14.1478
5 4 4 7 1521761 175691.19 151922.6 58 4.4 1.49 14.1917
6 5 5 8 1603841 383693.79 159930.8 253 4.3 1.91 12.9345
7 6 6 9 1642921 291692.27 163928.6 327 4.7 2.94 0.0000
8 7 7 10 1681881 187691.71 167927.6 55 4.8 0.69 14.0431
9 8 8 11 1682201 219695.98 167927.9 76 6.3 1.88 13.6858

for the coordinate extent is like following 127934.2, 427937.3, -22305.5, 535688.8 (xmin, xmax, ymin, ymax)

what I've done was made grid manually first and add grid in the function SpatialPixelsDataFrame

coor <- FHM %>% select("E","N")
grd <- GridTopology(c(-22306,127934), c(50,50), cells.dim = c(11166,5990))
FHM_grid <- SpatialPixelsDataFrame(points = coor, grid = grd, data = FHM)

FHM_grid <- SpatialPixelsDataFrame(points = coor, grid = grd, data = FHM)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2166 154 1994 2044 3814 8994
Error in getGridIndex(coordinates(points), grid) : this.idx out of range

could anyone help me out to solve this problem?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.