来自 terra 的错误:未使用的参数(类型 = "xyz")
Error from terra: unused argument (type = "xyz")
我正在尝试将 xyz 坐标和值转换为 SpatRaster,但是,我不断收到以下错误:
unused argument (type = "xyz")
即使我 运行 它是:
rast(re, type="xyz")
这是我正在处理的数据:
structure(list(x = c(-1.18187405993761, -2.90073956374817, -3.08021949587297,
-6.31776134843182, -6.31776134843182, -3.3218270968102, -3.57033777205992,
-5.30991249880795, -4.22612983174668, -2.20352905818646, -2.19662598387397,
-3.21828098212281, -6.29014905118185, -3.39776091424761, -3.39776091424761,
-3.77052692712219, -4.10877756843431, -6.88381344205618, -3.07331642156048,
-2.85932111787322, -4.98546800612082, -2.52797355087359, -3.21137790781032,
-4.42631898680895, -5.06140182355823, -3.22518405643531, -3.63246544087235,
-3.37014861699764, -2.90764263806066, -4.5643804730588, -3.75672077849721,
-3.19757175918534, -2.57629507106104, -1.68579848474954, -4.18471138587172,
-2.9628672325606, -3.95000685924699, -1.58225237006216, -2.78338730043581,
-6.22111830805693, -5.82764307224487, -6.0692506731821, -7.90546844030503,
-6.64910891543144, -3.01809182706054, -0.64343426356322, -2.16211061231151,
-4.63341121618372, -2.85932111787322, -1.16806791131263), y = c(60.1326022736268,
58.9521765661906, 58.4482521413787, 58.2204506890665, 58.213547614754,
57.709623189942, 57.6474955211296, 57.6129801495672, 57.4887248119423,
57.2056987651301, 57.1780864678801, 57.0400249816303, 57.0124126843803,
57.0124126843803, 57.0055096100678, 56.7155804889432, 56.5291974825059,
56.4946821109434, 56.4532636650685, 56.377329847631, 56.0252730576939,
56.0045638347565, 55.970048463194, 55.8457931255692, 55.8388900512567,
55.8250839026317, 55.7008285650068, 55.7008285650068, 55.5420578558195,
55.4799301870071, 55.4178025181946, 55.3142564035073, 55.2314195117573,
55.2176133631324, 55.10026109982, 54.9345873163202, 54.9276842420077,
54.7689135328204, 54.6722704924455, 54.651561269508, 54.6032397493206,
54.4513721144457, 54.4375659658207, 54.3478259997583, 54.3409229254458,
54.1062183988211, 54.0993153245086, 54.0855091758836, 54.0786061015711,
53.9198353923838), z = c(71, 66, 124, 109, 110, 75, 65, 64, 60,
35, 29, 8, 98, 18, 17, 42, 4, 115, 88, 72, 9, 33, 38, 92, 21,
93, 26, 12, 15, 7, 69, 39, 63, 87, 43, 25, 114, 34, 89, 1, 108,
56, 76, 5, 47, 55, 81, 100, 86, 6)), row.names = c(159527L, 417317L,
527448L, 576776L, 578285L, 688876L, 702421L, 709714L, 737033L,
799195L, 805232L, 835264L, 840855L, 841274L, 842783L, 906107L,
946801L, 953944L, 963550L, 980180L, 1056831L, 1061714L, 1069160L,
1096146L, 1097563L, 1100847L, 1127950L, 1127988L, 1162762L, 1176103L,
1189801L, 1212517L, 1230715L, 1233862L, 1259153L, 1295546L, 1296912L,
1331962L, 1352914L, 1356943L, 1367563L, 1400726L, 1403478L, 1423277L,
1425312L, 1476962L, 1478251L, 1480911L, 1482677L, 1517629L), class = "data.frame")
问题是re
是一个data.frame
,没有rast-data.frame
方法。因为 data.frame 是一种列表类型,并且因为有一个 rast-list
方法,所以这就是它的去向,如您所见:
library(terra)
r <- rast(re)
#Error: [rast,list] none of the elements of x are a SpatRaster
错误发生是因为 list
方法需要一个 SpatRaster
对象的列表。 xyz=TRUE
不是此方法的参数,因此如果您使用它,首先会发生错误:
r <- rast(re, type="xyz")
#Error in .local(x, ...) : unused argument (type = "xyz")
你要找的是rast-matrix
方法:
m <- as.matrix(re)
r <- rast(m, type="xyz")
r
#class : SpatRaster
#dimensions : 901, 1054, 1 (nrow, ncol, nlyr)
#resolution : 0.006903074, 0.006903074 (x, y)
#extent : -7.90892, -0.6330797, 53.91638, 60.13605 (xmin, xmax, ymin, ymax)
#coord. ref. :
#source : memory
#name : z
#min value : 1
#max value : 124
我在 terra
中添加了一个 rast,data.frame
方法,因此您的方法适用于版本 >= 1.3-7。
我正在尝试将 xyz 坐标和值转换为 SpatRaster,但是,我不断收到以下错误:
unused argument (type = "xyz")
即使我 运行 它是:
rast(re, type="xyz")
这是我正在处理的数据:
structure(list(x = c(-1.18187405993761, -2.90073956374817, -3.08021949587297,
-6.31776134843182, -6.31776134843182, -3.3218270968102, -3.57033777205992,
-5.30991249880795, -4.22612983174668, -2.20352905818646, -2.19662598387397,
-3.21828098212281, -6.29014905118185, -3.39776091424761, -3.39776091424761,
-3.77052692712219, -4.10877756843431, -6.88381344205618, -3.07331642156048,
-2.85932111787322, -4.98546800612082, -2.52797355087359, -3.21137790781032,
-4.42631898680895, -5.06140182355823, -3.22518405643531, -3.63246544087235,
-3.37014861699764, -2.90764263806066, -4.5643804730588, -3.75672077849721,
-3.19757175918534, -2.57629507106104, -1.68579848474954, -4.18471138587172,
-2.9628672325606, -3.95000685924699, -1.58225237006216, -2.78338730043581,
-6.22111830805693, -5.82764307224487, -6.0692506731821, -7.90546844030503,
-6.64910891543144, -3.01809182706054, -0.64343426356322, -2.16211061231151,
-4.63341121618372, -2.85932111787322, -1.16806791131263), y = c(60.1326022736268,
58.9521765661906, 58.4482521413787, 58.2204506890665, 58.213547614754,
57.709623189942, 57.6474955211296, 57.6129801495672, 57.4887248119423,
57.2056987651301, 57.1780864678801, 57.0400249816303, 57.0124126843803,
57.0124126843803, 57.0055096100678, 56.7155804889432, 56.5291974825059,
56.4946821109434, 56.4532636650685, 56.377329847631, 56.0252730576939,
56.0045638347565, 55.970048463194, 55.8457931255692, 55.8388900512567,
55.8250839026317, 55.7008285650068, 55.7008285650068, 55.5420578558195,
55.4799301870071, 55.4178025181946, 55.3142564035073, 55.2314195117573,
55.2176133631324, 55.10026109982, 54.9345873163202, 54.9276842420077,
54.7689135328204, 54.6722704924455, 54.651561269508, 54.6032397493206,
54.4513721144457, 54.4375659658207, 54.3478259997583, 54.3409229254458,
54.1062183988211, 54.0993153245086, 54.0855091758836, 54.0786061015711,
53.9198353923838), z = c(71, 66, 124, 109, 110, 75, 65, 64, 60,
35, 29, 8, 98, 18, 17, 42, 4, 115, 88, 72, 9, 33, 38, 92, 21,
93, 26, 12, 15, 7, 69, 39, 63, 87, 43, 25, 114, 34, 89, 1, 108,
56, 76, 5, 47, 55, 81, 100, 86, 6)), row.names = c(159527L, 417317L,
527448L, 576776L, 578285L, 688876L, 702421L, 709714L, 737033L,
799195L, 805232L, 835264L, 840855L, 841274L, 842783L, 906107L,
946801L, 953944L, 963550L, 980180L, 1056831L, 1061714L, 1069160L,
1096146L, 1097563L, 1100847L, 1127950L, 1127988L, 1162762L, 1176103L,
1189801L, 1212517L, 1230715L, 1233862L, 1259153L, 1295546L, 1296912L,
1331962L, 1352914L, 1356943L, 1367563L, 1400726L, 1403478L, 1423277L,
1425312L, 1476962L, 1478251L, 1480911L, 1482677L, 1517629L), class = "data.frame")
问题是re
是一个data.frame
,没有rast-data.frame
方法。因为 data.frame 是一种列表类型,并且因为有一个 rast-list
方法,所以这就是它的去向,如您所见:
library(terra)
r <- rast(re)
#Error: [rast,list] none of the elements of x are a SpatRaster
错误发生是因为 list
方法需要一个 SpatRaster
对象的列表。 xyz=TRUE
不是此方法的参数,因此如果您使用它,首先会发生错误:
r <- rast(re, type="xyz")
#Error in .local(x, ...) : unused argument (type = "xyz")
你要找的是rast-matrix
方法:
m <- as.matrix(re)
r <- rast(m, type="xyz")
r
#class : SpatRaster
#dimensions : 901, 1054, 1 (nrow, ncol, nlyr)
#resolution : 0.006903074, 0.006903074 (x, y)
#extent : -7.90892, -0.6330797, 53.91638, 60.13605 (xmin, xmax, ymin, ymax)
#coord. ref. :
#source : memory
#name : z
#min value : 1
#max value : 124
我在 terra
中添加了一个 rast,data.frame
方法,因此您的方法适用于版本 >= 1.3-7。