关于将 .nc 文件转换为 .tiff 文件,我遇到了丢失像素地理信息的问题。我知道其他用户也遇到了同样的问题,并试图通过 kotlin 解决但失败了。我更喜欢使用 R 的解决方案。有关 kotlin 方法 URL,请参见此处:https ://gis.stackexchange.com/questions/259700/converting-sentinel-3-data-netcdf-to-geotiff
我下载了 ESA 的免费 Sentinel-3 数据(网址:https ://scihub.copernicus.eu/dhus/#/home )。不幸的是,此数据以 .nc 格式提供,因此我想将其转换为 .tiff 格式。我已经尝试了各种方法,但都失败了。到目前为止我已经尝试过:
data_source <- 'D:/user_1/01_test_data/S3A_SL_1_RBT____20180708T093240_20180708T093540_20180709T141944_0179_033_150_2880_LN2_O_NT_003.SEN3/F1_BT_in.nc'
# define path to .nc-file
data_output <- 'D:/user_1/01_test_data/S3A_SL_1_RBT____20180708T093240_20180708T093540_20180709T141944_0179_033_150_2880_LN2_O_NT_003.SEN3/test.tif'
# define path of output .tiff-file
###################################################
# 1.) use gdal_translate via Windows cmd-line in R
# see here URL:https://stackoverflow.com/questions/52046282/convert-netcdf-nc-to-geotiff
system(command = paste('gdal_translate -of GTiff -sds -a_srs epsg:4326', data_source, data_output))
# hand over character string to Windows cmd-line to use gdal_translate
###################################################
# 2.) use the raster-package
# see here URL:https://www.researchgate.net/post/How_to_convert_a_NetCDF4_file_to_GeoTIFF_using_R2
epsg4326 <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
# proj4-code
# URL:https://spatialreference.org/ref/epsg/wgs-84/proj4/
specific_band <- raster(data_source)
crs(specific_band) <- epsg4326
writeRaster(specific_band, filename = data_output)
# both approaches work, i can convert the files from .nc-format into .tiff-format, but i **loose the geoinformation for the pixels** and just get pixel coordinates instead of longlat-values.
我非常感谢任何保留像素地理信息的解决方案!
非常感谢,Explorer