从sen2r R包进行简单查询时出现错误

niknxzdl  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(84)

我试图使用sen2r R包加载一些Sentinel卫星图像,但遇到了问题。简而言之,即使是文档中最简单的示例也不起作用。此示例如下:

json_path <- build_example_param_file()

if (is_gcloud_configured()) {
  out_paths_2 <- sen2r(json_path)
} else {
  out_paths_2 <- character(0)
}

字符串
这是我收到的输出;其中一些消息似乎对结果没有影响,错误有点模糊,似乎是由于包使用的某些函数中的一个小错误引起的。

[2023-12-04 17:59:26] #### Starting sen2r execution. ####
Spherical geometry (s2) switched off
[2023-12-04 17:59:27] Searching for available SAFE products...
old-style crs object detected; please recreate object with a recent sf::st_crs()
old-style crs object detected; please recreate object with a recent sf::st_crs()
[2023-12-04 17:59:28] Querying Google Cloud (this can take a very long time)...
  |==========================================================================================| 100%Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘saveXML’ for signature ‘"NULL"’
Spherical geometry (s2) switched on


示例代码组成了一个默认的.json文件,其中包含函数的参数。该文件的内容如下:

{
  "preprocess": [true],
  "s2_levels": ["l1c", "l2a"],
  "sel_sensor": ["s2a", "s2b"],
  "online": [true],
  "server": ["gcloud"],
  "order_lta": [true],
  "downloader": ["builtin"],
  "overwrite_safe": [false],
  "rm_safe": ["no"],
  "max_cloud_safe": [100],
  "step_atmcorr": ["l2a"],
  "sen2cor_use_dem": [null],
  "sen2cor_gipp": [null],
  "timewindow": ["2020-08-01", "2020-08-01"],
  "timeperiod": ["full"],
  "extent": ["C:/Users/pthom/AppData/Local/R/win-library/4.3/sen2r/extdata/vector/barbellino.geojson"],
  "s2tiles_selected": [null],
  "s2orbits_selected": [null],
  "list_prods": ["BOA", "SCL"],
  "list_indices": ["MSAVI2", "NDVI"],
  "list_rgb": ["RGB432B", "RGB843B"],
  "rgb_ranges": [
    [0, 2500],
    [
      [0, 7500],
      [0, 2500],
      [0, 2500]
    ]
  ],
  "index_source": ["BOA"],
  "mask_type": [null],
  "max_mask": [100],
  "mask_smooth": [0],
  "mask_buffer": [0],
  "clip_on_extent": [true],
  "extent_as_mask": [false],
  "extent_name": ["sen2r"],
  "reference_path": [null],
  "res": [null],
  "res_s2": ["10m"],
  "unit": ["Meter"],
  "proj": [null],
  "resampling": ["near"],
  "resampling_scl": ["near"],
  "outformat": ["GTiff"],
  "rgb_outformat": ["GTiff"],
  "index_datatype": ["Int16"],
  "compression": ["DEFLATE"],
  "rgb_compression": ["DEFLATE"],
  "overwrite": [false],
  "path_l1c": ["C:/Users/pthom/DOCUME~1/SEN2R~1/safe"],
  "path_l2a": ["C:/Users/pthom/DOCUME~1/SEN2R~1/safe"],
  "path_tiles": [null],
  "path_merged": [null],
  "path_out": ["C:\\Users\\pthom\\AppData\\Local\\Temp\\RtmpyAjAd3\\sen2r_out_120814e04eb2"],
  "path_rgb": [""],
  "path_indices": [""],
  "path_subdirs": [true],
  "thumbnails": [true],
  "log": [null],
  "parallel": [false],
  "processing_order": ["by_groups"],
  "pkg_version": ["1.6.0"]
}


为了确定查询的空间范围,此文件调用sen2r包提供的geoJSON文件。此文件的内容显示在此处。

{
"type": "FeatureCollection",
"name": "barbellino",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32632" } },
"features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 580560.0, 5101700.0 ], [ 580680.0, 5101700.0 ], [ 580800.0, 5101820.0 ], [ 580800.0, 5102120.0 ], [ 580660.0, 5102120.0 ], [ 580560.0, 5102020.0 ], [ 580560.0, 5101700.0 ] ] ] } }
]
}


我使用的是R 4.3.2和sen 2 r版本1.6.0。我已经尝试更新我设备上所有安装的R软件包,使用install_github安装sen 2 r,并在网上查看了很多其他类似的问题。可能只是这个问题无法解决,除非软件包的创建者能够恢复一些东西;我不确定。看起来这个软件包最近已经更新了,以反映一些非R软件的变化,所以大多数关于sen2r的问题都来自旧版本。如果有任何其他信息对你有帮助,请告诉我。或者你有什么建议
谢谢你,谢谢

6mzjoqzu

6mzjoqzu1#

您的时间范围内只有一个日期:“2022-08-01”。
设置为类似于:

"timewindow": ["2020-07-01", "2020-09-01"]

字符串
后重试

编辑...

我将你的js.json和上面的geojson扩展文件复制到我的计算机上的一个目录中,并运行sen2r命令,如下所示(删除一些配置选项,以简化):

library(sen2r)    
sen2r(param_list = "~/work/tmp/PeterThompson/config.json", gui = FALSE, timewindow = c('2020-07-01', '2020-09-01'), rm_safe = "no", extent = "~/work/tmp/PeterThompson/aoi.geojson", extent_name = "barbellino", path_l1c = "~/work/tmp/PeterThompson/", path_l2a = "~/work/tmp/PeterThompson/", path_out = "~/work/tmp/PeterThompson/", overwrite_safe = FALSE, list_prods = "BOA", list_indices = "SAVI")
list.files("~/work/tmp/PeterThompson/BOA", pattern = ".*tif")
 [1] "S2A2A_20200707_022_barbellino_BOA_10.tif" "S2A2A_20200710_065_barbellino_BOA_10.tif"
 [3] "S2A2A_20200717_022_barbellino_BOA_10.tif" "S2A2A_20200720_065_barbellino_BOA_10.tif"
 [5] "S2A2A_20200727_022_barbellino_BOA_10.tif" "S2A2A_20200730_065_barbellino_BOA_10.tif"
 [7] "S2A2A_20200806_022_barbellino_BOA_10.tif" "S2A2A_20200809_065_barbellino_BOA_10.tif"
 [9] "S2A2A_20200816_022_barbellino_BOA_10.tif" "S2A2A_20200819_065_barbellino_BOA_10.tif"
[11] "S2A2A_20200826_022_barbellino_BOA_10.tif" "S2A2A_20200829_065_barbellino_BOA_10.tif"
[13] "S2B2A_20200702_022_barbellino_BOA_10.tif" "S2B2A_20200705_065_barbellino_BOA_10.tif"
[15] "S2B2A_20200712_022_barbellino_BOA_10.tif" "S2B2A_20200715_065_barbellino_BOA_10.tif"
[17] "S2B2A_20200722_022_barbellino_BOA_10.tif" "S2B2A_20200725_065_barbellino_BOA_10.tif"
[19] "S2B2A_20200801_022_barbellino_BOA_10.tif" "S2B2A_20200804_065_barbellino_BOA_10.tif"
[21] "S2B2A_20200811_022_barbellino_BOA_10.tif" "S2B2A_20200814_065_barbellino_BOA_10.tif"
[23] "S2B2A_20200821_022_barbellino_BOA_10.tif" "S2B2A_20200824_065_barbellino_BOA_10.tif"
[25] "S2B2A_20200831_022_barbellino_BOA_10.tif"


此代码成功下载了25个SAFE目录,并创建了BOA和SAVI产品。
也许你可以从简单的东西开始,如果它有效,尝试添加其他产品。

相关问题