将 NSIDC .nc 和 .xml 文件导入 R 时出现问题

问题描述 投票:0回答:1

我正在尝试将每日海冰浓度网格以栅格/SpatRaster 格式从 NSIDC 导入到 R 中。

NSIDC 网站生成一个 Python 脚本来下载所需的文件(https://nsidc.org/data/data-access-tool/NSIDC-0051/versions/2)。运行此脚本时,每天会下载两个文件:

NSIDC0051_SEAICE_PS_N25km_19790101_v2.0.nc NSIDC0051_SEAICE_PS_N25km_19790101_v2.0.nc.xml

每月自动下载两个附加文件(不知道为什么,因为这应该是每日数据):

NSIDC0051_SEAICE_PS_N25km_197901_v2.0.nc NSIDC0051_SEAICE_PS_N25km_197901_v2.0.nc.xml

我尝试使用多种方法导入与每日浓度相对应的.nc 文件。我尝试使用该功能

terra::rast()

> sea_ice <- terra::rast("04_raw_data/sea_ice/NSIDC_05_2024/NSIDC0051_SEAICE_PS_N25km_19790101_v2.0.nc")
Error: [rast] cannot open this file as a SpatRaster: NSIDC_05_2024/NSIDC0051_SEAICE_PS_N25km_19790101_v2.0.nc
In addition: Warning message:
`NSIDC0051_SEAICE_PS_N25km_19790101_v2.0.nc' not recognized as a supported file format. (GDAL error 4)

我尝试过使用

ncdf4::nc_open
。这不会产生错误,但是,R 对象中似乎没有任何海冰浓度测量值:

> nc_file <- nc_open("NSIDC0051_SEAICE_PS_N25km_19790101_v2.0.nc")
> print(nc_file)
File NSIDC0051_SEAICE_PS_N25km_19790101_v2.0.nc (NC_FORMAT_NETCDF4):

     1 variables (excluding dimension variables):
        char crs[]   (Contiguous storage)  
            grid_mapping_name: polar_stereographic
            straight_vertical_longitude_from_pole: -45
            false_easting: 0
            false_northing: 0
            latitude_of_projection_origin: 90
            standard_parallel: 70
            long_name: NSIDC_NH_PolarStereo_25km
            longitude_of_prime_meridian: 0
            semi_major_axis: 6378273
            inverse_flattening: 298.279411123064
            proj4text: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs
            crs_wkt: PROJCS["NSIDC Sea Ice Polar Stereographic North",GEOGCS["Unspecified datum based upon the Hughes 1980 ellipsoid",DATUM["Not_specified_based_on_Hughes_1980_ellipsoid",SPHEROID["Hughes 1980",6378273,298.279411123061,AUTHORITY["EPSG","7058"]],AUTHORITY["EPSG","6054"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4054"]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",70],PARAMETER["central_meridian",-45],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","3411"]]
            spatial_ref: PROJCS["NSIDC Sea Ice Polar Stereographic North",GEOGCS["Unspecified datum based upon the Hughes 1980 ellipsoid",DATUM["Not_specified_based_on_Hughes_1980_ellipsoid",SPHEROID["Hughes 1980",6378273,298.279411123061,AUTHORITY["EPSG","7058"]],AUTHORITY["EPSG","6054"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4054"]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",70],PARAMETER["central_meridian",-45],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","3411"]]
            srid: urn:ogc:def:crs:EPSG::3411
            GeoTransform: -3850000 25000 0 5850000 0 -25000 

     3 dimensions:
        x  Size:304 
            standard_name: projection_x_coordinate
            coverage_content_type: coordinate
            long_name: x
            short_name: x
            axis: X
            units: meters
            valid_range: -3850000
             valid_range: 3750000
        y  Size:448 
            standard_name: projection_y_coordinate
            coverage_content_type: coordinate
            long_name: y
            short_name: y
            axis: Y
            units: meters
            valid_range: -5350000
             valid_range: 5850000
        time  Size:1   *** is unlimited *** 
            standard_name: time
            coverage_content_type: coordinate
            units: days since 1970-01-01 00:00:00
            long_name: ANSI date
            calendar: standard
            axis: T

我不明白为什么三维是时间,而不是海冰浓度。

最后,我尝试了 raster::raster 和 raster::brick 函数,它们产生以下错误:

>     file_l <- raster(NSIDC0051_SEAICE_PS_N25km_19790101_v2.0.nc)
Error in if (ndims == 1) { : argument is of length zero

我相信问题来自于我正在做的事情,而不是来自 NSIDC 文件。所以我现在想知道 .xml 文件是否有用并且应该沿着相应的 .nc 文件打开,但我在网上没有找到任何相关信息。知道这里发生了什么吗?

谢谢

r raster ncdf4
1个回答
0
投票

我意识到早些年,每隔一个 .nc 文件都无法读取,而其他文件则工作正常。我认为这是因为现在卫星测量是每隔一天进行一次。不知道为什么 NSIDC 为缺失的日子添加了虚拟文件。看起来很混乱。

© www.soinside.com 2019 - 2024. All rights reserved.