GDALを使用してNetCDFファイルをGeoTIFFに変換しますか?


10

英国の雨の日数のデータを含むNetCDFファイルがあります。それをGeoTIFFに変換したいのですが、GDALを正しくジオリファレンスできません。以下のgdalinfoからのダンプを参照してください。

「raindays_tmean_abs」変数を示すシングルバンドTIFFが必要です。「lat」および「lon」変数には、英国にデータを配置するための適切な最小値/最大値があるようですが、gdal_translateで変換すると、アフリカの西海岸に到達します。

最初のディメンションが「時間または垂直」ディメンションではないという警告があります。私はgdalがデータが特定の順序であることを期待していることを読んだので、おそらくこれが問題ですが、それを変更する方法がわかりません。

このデータを変換/再投影するにはどうすればよいですか?

gdalinfo NETCDF:RainDays1_1961-1990_LTA_25km.nc

Warning 1: dimension #0 (meaning_period) is not a Time or Vertical dimension.
Driver: netCDF/Network Common Data Format
Files: RainDays1_1961-1990_LTA_25km.nc
       RainDays1_1961-1990_LTA_25km.nc.aux.xml
Size is 39, 52
Coordinate System is `'
Origin = (-17.650008352179277,11.329999312758446)
Pixel Size = (0.219999614514803,-0.219999998807907)
Metadata:
  axis_0#units=
  meaning_period#comment=Meaning periods are all months (12) beginning January, all seasons (4) beginning Winter (DJF) and Annual (1)
  meaning_period#long_name=meaning_period
  meaning_period#units=
  NC_GLOBAL#Conventions=CF-1.0
  NETCDF_DIM_EXTRA={meaning_period}
  NETCDF_DIM_meaning_period_DEF={17,6}
  NETCDF_DIM_meaning_period_VALUES={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
  raindays_tmean_abs#comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
  raindays_tmean_abs#coordinates=lon lat
  raindays_tmean_abs#long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
  raindays_tmean_abs#missing_value=1e+020
  raindays_tmean_abs#name=rain_days
  raindays_tmean_abs#title=rain_days
  raindays_tmean_abs#units=days
  rlat#axis=Y
  rlat#bounds=bounds_rlat
  rlat#long_name=latitude in rotated pole grid
  rlat#standard_name=grid_latitude
  rlat#units=degrees
  rlon#axis=X
  rlon#bounds=bounds_rlon
  rlon#long_name=longitude in rotated pole grid
  rlon#modulo=360
  rlon#standard_name=grid_longitude
  rlon#topology=circular
  rlon#units=degrees
Subdatasets:
  SUBDATASET_1_NAME=NETCDF:"RainDays1_1961-1990_LTA_25km.nc":bounds_rlat
  SUBDATASET_1_DESC=[52x2] bounds_rlat (64-bit floating-point)
  SUBDATASET_2_NAME=NETCDF:"RainDays1_1961-1990_LTA_25km.nc":bounds_rlon
  SUBDATASET_2_DESC=[39x2] bounds_rlon (64-bit floating-point)
  SUBDATASET_3_NAME=NETCDF:"RainDays1_1961-1990_LTA_25km.nc":lat
  SUBDATASET_3_DESC=[52x39] latitude (32-bit floating-point)
  SUBDATASET_4_NAME=NETCDF:"RainDays1_1961-1990_LTA_25km.nc":lon
  SUBDATASET_4_DESC=[52x39] longitude (32-bit floating-point)
  SUBDATASET_5_NAME=NETCDF:"RainDays1_1961-1990_LTA_25km.nc":raindays_tmean_abs
  SUBDATASET_5_DESC=[17x52x39] raindays_tmean_abs (32-bit floating-point)
Geolocation:
  LINE_OFFSET=0
  LINE_STEP=1
  PIXEL_OFFSET=0
  PIXEL_STEP=1
  SRS=GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]
  X_BAND=1
  X_DATASET=NETCDF:"RainDays1_1961-1990_LTA_25km.nc":lon
  Y_BAND=1
  Y_DATASET=NETCDF:"RainDays1_1961-1990_LTA_25km.nc":lat
Corner Coordinates:
Upper Left  ( -17.6500084,  11.3299993) 
Lower Left  ( -17.6500084,  -0.1100006) 
Upper Right (  -9.0700234,  11.3299993) 
Lower Right (  -9.0700234,  -0.1100006) 
Center      ( -13.3600159,   5.6099993) 
Band 1 Block=39x1 Type=Float32, ColorInterp=Undefined
  Min=10.658 Max=22.949 
  Minimum=10.658, Maximum=22.949, Mean=15.625, StdDev=3.151
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=0
    NETCDF_VARNAME=raindays_tmean_abs
    STATISTICS_MAXIMUM=22.949373245239
    STATISTICS_MEAN=15.624619410087
    STATISTICS_MINIMUM=10.657625198364
    STATISTICS_STDDEV=3.1508820627895
    title=rain_days
    units=days
Band 2 Block=39x1 Type=Float32, ColorInterp=Undefined
  Min=7.893 Max=17.172 
  Minimum=7.893, Maximum=17.172, Mean=11.591, StdDev=2.282
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=1
    NETCDF_VARNAME=raindays_tmean_abs
    STATISTICS_MAXIMUM=17.172254562378
    STATISTICS_MEAN=11.591275386767
    STATISTICS_MINIMUM=7.8926663398743
    STATISTICS_STDDEV=2.28225356537
    title=rain_days
    units=days
Band 3 Block=39x1 Type=Float32, ColorInterp=Undefined
  Min=9.700 Max=21.762 
  Minimum=9.700, Maximum=21.762, Mean=13.882, StdDev=2.988
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=2
    NETCDF_VARNAME=raindays_tmean_abs
    STATISTICS_MAXIMUM=21.761842727661
    STATISTICS_MEAN=13.88236379732
    STATISTICS_MINIMUM=9.7001943588257
    STATISTICS_STDDEV=2.9875935432638
    title=rain_days
    units=days
Band 4 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=3
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 5 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=4
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 6 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=5
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 7 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=6
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 8 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=7
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 9 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=8
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 10 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=9
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 11 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=10
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 12 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=11
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 13 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=12
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 14 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=13
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 15 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=14
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 16 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=15
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days
Band 17 Block=39x1 Type=Float32, ColorInterp=Undefined
  NoData Value=1.0000000200408773e+020
  Metadata:
    comment=Converted from UKCP09 monthly data to climatologies and then averaged to 25km rotated pole grid.
    coordinates=lon lat
    long_name=Number of days per meaning period having a rainfall >= 1 mm (days)
    missing_value=1e+020
    name=rain_days
    NETCDF_DIM_meaning_period=16
    NETCDF_VARNAME=raindays_tmean_abs
    title=rain_days
    units=days

gdalinfo NETCDF:RainDays1_1961-1990_LTA_25km.nc:lon

Driver: netCDF/Network Common Data Format
Files: RainDays1_1961-1990_LTA_25km.nc
       RainDays1_1961-1990_LTA_25km.nc.aux.xml
Size is 39, 52
Coordinate System is `'
Origin = (-17.650008352179277,11.329999312758446)
Pixel Size = (0.219999614514803,-0.219999998807907)
Metadata:
  axis_0#units=
  lon#long_name=longitude
  lon#missing_value=1e+020
  lon#name=lon
  lon#standard_name=longitude
  lon#units=degrees_east
  meaning_period#comment=Meaning periods are all months (12) beginning January, all seasons (4) beginning Winter (DJF) and Annual (1)
  meaning_period#long_name=meaning_period
  meaning_period#units=
  NC_GLOBAL#Conventions=CF-1.0
  rlat#axis=Y
  rlat#bounds=bounds_rlat
  rlat#long_name=latitude in rotated pole grid
  rlat#standard_name=grid_latitude
  rlat#units=degrees
  rlon#axis=X
  rlon#bounds=bounds_rlon
  rlon#long_name=longitude in rotated pole grid
  rlon#modulo=360
  rlon#standard_name=grid_longitude
  rlon#topology=circular
  rlon#units=degrees
Corner Coordinates:
Upper Left  ( -17.6500084,  11.3299993) 
Lower Left  ( -17.6500084,  -0.1100006) 
Upper Right (  -9.0700234,  11.3299993) 
Lower Right (  -9.0700234,  -0.1100006) 
Center      ( -13.3600159,   5.6099993) 
Band 1 Block=39x1 Type=Float32, ColorInterp=Undefined
  Min=-15.830 Max=3.672 
  Minimum=-15.830, Maximum=3.672, Mean=-5.246, StdDev=4.393
  NoData Value=1.0000000200408773e+020
  Metadata:
    long_name=longitude
    missing_value=1e+020
    name=lon
    NETCDF_VARNAME=lon
    standard_name=longitude
    STATISTICS_MAXIMUM=3.671746969223
    STATISTICS_MEAN=-5.2457962955782
    STATISTICS_MINIMUM=-15.830010414124
    STATISTICS_STDDEV=4.3927366732513
    units=degrees_east

gdalinfo NETCDF:RainDays1_1961-1990_LTA_25km.nc:lat

Driver: netCDF/Network Common Data Format
Files: RainDays1_1961-1990_LTA_25km.nc
       RainDays1_1961-1990_LTA_25km.nc.aux.xml
Size is 39, 52
Coordinate System is `'
Origin = (-17.650008352179277,11.329999312758446)
Pixel Size = (0.219999614514803,-0.219999998807907)
Metadata:
  axis_0#units=
  lat#long_name=latitude
  lat#missing_value=1e+020
  lat#name=lat
  lat#standard_name=latitude
  lat#units=degrees_north
  meaning_period#comment=Meaning periods are all months (12) beginning January, all seasons (4) beginning Winter (DJF) and Annual (1)
  meaning_period#long_name=meaning_period
  meaning_period#units=
  NC_GLOBAL#Conventions=CF-1.0
  rlat#axis=Y
  rlat#bounds=bounds_rlat
  rlat#long_name=latitude in rotated pole grid
  rlat#standard_name=grid_latitude
  rlat#units=degrees
  rlon#axis=X
  rlon#bounds=bounds_rlon
  rlon#long_name=longitude in rotated pole grid
  rlon#modulo=360
  rlon#standard_name=grid_longitude
  rlon#topology=circular
  rlon#units=degrees
Corner Coordinates:
Upper Left  ( -17.6500084,  11.3299993) 
Lower Left  ( -17.6500084,  -0.1100006) 
Upper Right (  -9.0700234,  11.3299993) 
Lower Right (  -9.0700234,  -0.1100006) 
Center      ( -13.3600159,   5.6099993) 
Band 1 Block=39x1 Type=Float32, ColorInterp=Undefined
  Min=47.594 Max=60.806 
  Minimum=47.594, Maximum=60.806, Mean=54.186, StdDev=3.229
  NoData Value=1.0000000200408773e+020
  Metadata:
    long_name=latitude
    missing_value=1e+020
    name=lat
    NETCDF_VARNAME=lat
    standard_name=latitude
    STATISTICS_MAXIMUM=60.805950164795
    STATISTICS_MEAN=54.185836173138
    STATISTICS_MINIMUM=47.594329833984
    STATISTICS_STDDEV=3.228754901642
    units=degrees_north

...残念ながら、まだ50件の評判がありません。コメントを残す代わりに「回答」します。Windowsのcmd-lineを使用したgdalソリューションに非常に興味があります。Rを使用して、gdal_translateコマンドをcmd-lineに渡します。私がこれまでに試したことは次のとおりです: `` `data_source <-'D:/user1/01_data/input.nc' data_output <-'D:/user1/01_data/output.tif' system(command = paste( 'gdal_translate- of GTiff -sds -a_srs epsg:4326 '、data_source、data_output)) `` `これは機能していますが、crs-informationが失われています!誰かがcrs情報を保持する方法を知っていますか?
ExploreR 2019

回答:


3

netcdfは回転極グリッドを使用します。GDALはそれを処理できません。

そのためのチケットがあります:http : //trac.osgeo.org/gdal/ticket/4285これはいくつかの回避策を提供します。

GMTには、grdrotater回転した極で動作するはずのツールがありますが、まだ使用していません。

GRASSに慣れている場合は、次の回避策を試すことができます。

http://osgeo-org.1560.x6.nabble.com/NetCDF-rotated-pole-td4634232.html


2

gdal_translateで変換しようとしましたか?

通常は、次の2つの可能性のいずれかを使用して機能します。

最初の解決策:すべてのサブデータセットを手動で抽出する

gdal_translate -of VRT NETCDF:"RainDays1_1961-1990_LTA_25km.nc":raindays_tmean_abs output_RD.vrt 
gdal_translate -of VRT NETCDF:"RainDays1_1961-1990_LTA_25km.nc":lat output_lat.vrt 
gdal_translate -of VRT NETCDF:"RainDays1_1961-1990_LTA_25km.nc":lon output_lon.vrt

2番目の解決策:gdalにサブデータセットを自動的に抽出させます

gdal_translate -of VRT -sds RainDays1_1961-1990_LTA_25km.nc output.vrt

2番目のソリューションは、すべてのサブデータセットを個別のファイルに抽出します。

を含める必要があるかもしれません

-a_srs epsg:4326

国旗


0

あなたのピクセルサイズはあなたのファイルで異なります、GDALはそれについて不平を言います、見てください:

Afaik、あなたは等しいピクセルサイズを持っている必要があります。そのためにグリッドをリサンプルするか、グリッドを最初からやり直す必要があります。GMTはそのための素晴らしいツールです。

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.