Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何对光栅进行dput()_R_R Raster - Fatal编程技术网

R 如何对光栅进行dput()

R 如何对光栅进行dput(),r,r-raster,R,R Raster,如果使用dput()输出使用光栅包创建的光栅对象的结构,则将该结构分配回新对象会引发错误 Error in datanotation %in% c("LOG1S", "INT1S", "INT2S", "INT4S", "INT1U", : error in evaluating the argument 'x' in selecting a method for function '%in%': Error: object 'datanotation' not found dput的

如果使用dput()输出使用
光栅
包创建的光栅对象的结构,则将该结构分配回新对象会引发错误

Error in datanotation %in% c("LOG1S", "INT1S", "INT2S", "INT4S", "INT1U",  : 
  error in evaluating the argument 'x' in selecting a method for function '%in%': Error: object 'datanotation' not found
dput的输出示例,用于在其上进行测试:

rast <- new("RasterLayer", file = new(".RasterFile"
                         , name = ""
                         , datanotation = "FLT4S"
                         , byteorder = "little"
                         , nodatavalue = -Inf
                         , NAchanged = FALSE
                         , nbands = 1L
                         , bandorder = "BIL"
                         , offset = 0L
                         , toptobottom = TRUE
                         , blockrows = 0L
                         , blockcols = 0L
                         , driver = ""
                         , open = FALSE
            )
            , data = new(".SingleLayerData"
                         , values = c(NA, NA, NA, NA, 27.7696047300953, 25.8297302967319, 21.8282877533719, 
                                      18.2355885882618, 27.0557882676846, 27.2210269605054, NA, NA, 
                                      NA, NA, NA, NA, NA, NA, NA, NA, NA, 27.7812364734848, 27.405183119753, 
                                      24.2674419226904, 21.1096354803572, 19.7839120235376, 28.0337762198564, 
                                      30.3552042477317, 27.9129238649901, NA, NA, NA, NA, NA, NA, NA, 
                                      NA, NA, NA, 27.8602581108286, 25.5695030720577, 19.308317452836, 
                                      20.2224030952562, 19.8943689815922, 26.0737945219631, 29.8730429910469, 
                                      30.0356550838097, NA, NA, NA, NA, NA, NA, NA, NA, NA, 27.9364248138976, 
                                      26.9457930700303, 23.0304323166943, 19.4650798632613, 19.0999036995668, 
                                      17.5193560841074, 27.7251998095169, 28.4496104452209, 28.9315408261731, 
                                      NA, NA, NA, NA, NA, NA, NA, NA, NA, 26.8544908125766, 25.0566493895284, 
                                      19.392461671792, 17.9138961574326, 18.457466509715, 16.2828861956587, 
                                      24.3601694045773, 28.1808209395655, 28.9282707782622, 26.6332021683416, 
                                      NA, NA, NA, NA, NA, NA, NA, 25.7558302469057, 25.8550702427802, 
                                      22.5693001232205, 19.6993922601795, 16.1425172340908, 18.5221217322922, 
                                      15.6749250516081, 23.7808882591915, 26.8347423074187, 27.2630654814702, 
                                      25.9184967686647, NA, NA, NA, NA, NA, NA, NA, 24.8123372469289, 
                                      21.9120014347897, 21.8593245154305, 18.7720082061109, 19.7574885247249, 
                                      18.4980326509342, 16.3585539605331, 24.9138993320561, 25.2434828477134, 
                                      24.163634092843, 21.0163621891882, 20.415437668758, NA, NA, NA, 
                                      NA, NA, NA, 24.1877819407117, 20.6452893546199, 20.1902008603325, 
                                      19.3002926063194, 16.8587312480956, 16.2594198755341, 19.2032612963314, 
                                      23.627249155838, 20.2610810034085, 20.512646252079, 21.2108132984962, 
                                      21.3929956864179, 22.5462104762584, NA, NA, NA, NA, 28.1377507911064, 
                                      26.6783600800768, 21.9226216069185, 18.7325546681671, 19.3040954243679, 
                                      18.9295032049331, 16.9754437056141, 18.4150075374079, 22.1472527043877, 
                                      23.0212426364059, 24.3613220176048, 23.8262550760194, 23.1817611577951, 
                                      23.5871416966677, 24.5249361302642, 24.8507563698565, 24.5380700828535, 
                                      24.6222669309606, 28.1310406991608, 26.6318516890262, 22.2093701933002, 
                                      18.5946021290531, 18.8365649393596, 19.1392679329481, 18.0261774155026, 
                                      15.4867865984622, 22.6594382919435, 24.0000969920539, 26.8590549383737, 
                                      25.3828920205212, 24.7396876533108, 24.2529425383968, 25.4417776029091, 
                                      25.4515553773556, 25.362837214521, 24.9104771169439, NA, 26.0466484214637, 
                                      22.5547365784066, 21.385068811716, 21.7011412999039, 21.5908931968994, 
                                      17.5042944634609, 16.1420136345859, 22.2389789351034, 24.9668657681713, 
                                      27.1669375893459, 26.7413589409561, 26.421134458086, 26.219636989708, 
                                      26.3182362528439, 26.4198369697735, 26.3436222765849, NA, NA, 
                                      NA, 23.0141531354431, 25.0932401677589, 21.6662460243741, 20.5190520941524, 
                                      18.375683158989, 21.0476911567136, 24.5643254483451, 26.328155553503, 
                                      26.272891752264, 27.9174179692592, 27.8104921435185, 27.3675508861065, 
                                      27.0387799062499, 26.7967626268208, NA, NA, NA, NA, 23.9459211033352, 
                                      27.0411266756461, 24.5366020483741, 21.827679045105, 20.9547907819176, 
                                      22.0691273897516, 23.4745553057174, 26.3462307150211, 28.3701287602482, 
                                      27.3758861302374, 27.3750656061461, 27.962003557149, 27.5345722331493, 
                                      NA, NA, NA, NA, NA, NA, 28.2432491874035, 25.6912040459346, 23.8651528078732, 
                                      21.6046243626329, 22.9131480337219, 23.819129269607, 26.3568262380137, 
                                      28.9188481472128, 28.1497370861287, 27.7360100735352, NA, NA, 
                                      NA, NA, NA, NA, NA, NA, NA, NA, 25.045874725646, 23.2493769507419, 
                                      23.1730515314323, 24.2038209656421, 28.3416254663092, 28.8959112067936, 
                                      NA, NA, NA, NA, NA, NA, NA)
                         , offset = 0
                         , gain = 1
                         , inmemory = TRUE
                         , fromdisk = FALSE
                         , isfactor = FALSE
                         , attributes = list()
                         , haveminmax = TRUE
                         , min = 15.4867865984622
                         , max = 30.3552042477317
                         , band = 1L
                         , unit = ""
                         , names = "MAT_eclp"
            )
            , legend = new(".RasterLegend"
                           , type = character(0)
                           , values = logical(0)
                           , color = logical(0)
                           , names = logical(0)
                           , colortable = logical(0)
            )
            , title = character(0)
            , extent = new("Extent"
                           , xmin = 832565.530013465
                           , xmax = 2452565.53001346
                           , ymin = 383803.949813352
                           , ymax = 1733803.94981335
            )
            , rotated = FALSE
            , rotation = new(".Rotation"
                             , geotrans = numeric(0)
                             , transfun = function () 
                               NULL
            )
            , ncols = 18L
            , nrows = 15L
            , crs = new("CRS"
                        , projargs = "+proj=aea +lat_1=20 +lat_2=-23 +lat_0=0 +lon_0=25 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
            )
            , history = list()
            , z = list()
)

如何从文本版本加载光栅并避免此错误?

这是一个错误,原因是
.RasterFile
对象(属于
光栅层
的一部分)的有效性检查出错。如图所示:

x <- new(".RasterFile")
validObject(x)
#Error in datanotation %in% c("LOG1S", "INT1S", "INT2S", "INT4S", "INT1U",  : 
#  object 'datanotation' not found

x问这个问题的原因是我认为我遇到了与光栅内容相关的问题,我想用一种简单的方法发布光栅的结构以及一个问题等等。无论如何都解决了我的问题,所以实际上不再需要这个了。我想这是一件不寻常的事情,因为大多数人只会在光栅文件上发布一个下载链接,如果需要它作为支持问题的数据,但我觉得问题应该尽可能独立,如果可能的话,不要依赖外部链接,但通常要做的是在内存中创建一个光栅层,如
r
x <- new(".RasterFile")
validObject(x)
#Error in datanotation %in% c("LOG1S", "INT1S", "INT2S", "INT4S", "INT1U",  : 
#  object 'datanotation' not found