【问题标题】:How i can convert ncdf (of Sentinel_5_L2) files to geotiff?我如何将 ncdf(Sentinel_5_L2)文件转换为 geotiff?
【发布时间】:2021-11-17 14:52:45
【问题描述】:

我正在尝试使用 netcdf 文件制作 geotiff 文件。我有这个文件(Sentinel_5_L2)。但是我的代码没有运行。有谁知道创建 geotiff 文件?

文件https://wetransfer.com/downloads/7c5692bef082bc64999e10d8a7a91e8f20211116115821/7774f8

这是错误

Error in .local(x, ...) : 
  unused arguments (xmin = -179.996887207031, ymin = c(....)

这是代码。

library(ncdf4) 
library(raster) 
library(rgdal) 
library(ggplot2) 

nc_data <- nc_open("TROPOSIF_L2B_2018-06-01.nc")

lon <- ncvar_get(nc_data, "PRODUCT/longitude", verbose=TRUE)
lat <- ncvar_get(nc_data, "PRODUCT/latitude", verbose=TRUE)
SIF_743 <- ncvar_get(nc_data,"PRODUCT/SIF_743", verbose=TRUE)

r <- raster(t(SIF_743), xmin=min(lon), xmx=max(lon), ymin=(lat), ymx=max(lat), crs=CRS("+init=epsg:4326"))

r <- flip(r, direction='y')

plot(r)

【问题讨论】:

    标签: r raster geotiff ncdf4 sentinel-5p


    【解决方案1】:

    使用 gdal 可能更容易,更可靠:

    gdal_translate NETCDF:"Input_FileName.nc":variable_name Output_FileName.tif
    

    相关指导:https://nsidc.org/support/how/how-convert-golive-netcdf-variables-geotiff

    【讨论】:

      【解决方案2】:

      你可以的

      library(terra)
      nc <- rast("TROPOSIF_L2B_2018-06-01.nc")
      nc <- writeRaster(nc, "TROPOSIF_L2B_2018-06-01.tif")
      

      terra 在后台使用 GDAL。

      或者也许使用较旧的raster

      library(raster)
      ncr <- brick("TROPOSIF_L2B_2018-06-01.nc")
      ncr <- writeRaster(ncr, "TROPOSIF_L2B_2018-06-01.tif")
      

      但是,对于您的文件

      r <- rast("TROPOSIF_L2B_2018-06-01.nc")
      #Warning message:
      #[rast] GDAL did not find an extent. Cells not equally spaced?
      r
      #class       : SpatRaster 
      #dimensions  : 2711578, 7, 1  (nrow, ncol, nlyr)
      #resolution  : 0.1428571, 3.687889e-07  (x, y)
      #extent      : 0, 1, 0, 1  (xmin, xmax, ymin, ymax)
      #coord. ref. : lon/lat WGS 84 
      #source      : TOA_RFL 
      #varname     : TOA_RFL (TOA Reflectance at atmospheric windows within 665-785 nm) 
      #name        : TOA_RFL 
      #unit        :       - 
      

      换句话说,您可以将这些数据强制为栅格,但由于它们的间距不规则,这可能不正确。但也许这对您的用例来说是可以的。原则上,您可以将数据读取为点和光栅化或类似的解决方案。

      【讨论】:

        猜你喜欢
        • 2019-09-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-01
        • 2021-11-02
        • 1970-01-01
        • 2019-02-02
        相关资源
        最近更新 更多