กำลังแปลงไฟล์ NetCDF เป็น GeoTIFF โดยใช้ GDAL?


10

ฉันมีไฟล์ NetCDF ซึ่งมีข้อมูลตามจำนวนวันที่ฝนตกในสหราชอาณาจักร ฉันต้องการแปลงเป็น GeoTIFF แต่ไม่สามารถรับตำแหน่งทางภูมิศาสตร์ของ GDAL ได้อย่างถูกต้อง ดูการถ่ายโอนข้อมูลจาก gdalinfo ด้านล่าง

ฉันต้องการ TIFF หนึ่งวงที่แสดงตัวแปร "raindays_tmean_abs" ตัวแปร "lat" และ "lon" ดูเหมือนจะมีค่า min / max ที่สมเหตุสมผลเพื่อนำข้อมูลไปทั่วสหราชอาณาจักร แต่เมื่อฉันแปลงด้วย 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 ดังนั้นฉันจะ 'ตอบ' แทนที่จะออกความคิดเห็น ฉันจะสนใจโซลูชั่น gdal มากโดยใช้ windows cmd-line! ฉันใช้ R เพื่อมอบคำสั่ง gdal_translate ให้กับ cmd-line สิ่งที่ฉันลองมาแล้วคือ: `` `data_source <- 'D: /user1/01_data/input.nc' data_output <- 'D: /user1/01_data/output.tif' ระบบ (command = paste ('gdal_translate - ของ GTiff -sds -a_srs epsg: 4326 ', data_source, data_output)) `` `นี่ใช้งานได้ แต่ฉันกำลังสูญเสีย crs-information ! ไม่มีใครรู้วิธีเก็บข้อมูล crs!
ExploreR

คำตอบ:


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 หรือไม่

โดยปกติควรทำงานโดยใช้หนึ่งในสองวิธีดังนี้:

วิธีแรก: แยกทุกชุดย่อยด้วยตนเอง

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

วิธีที่สอง: ให้ gdal แยกชุดย่อยโดยอัตโนมัติ

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

โซลูชันที่สองจะแยกชุดย่อยทั้งหมดเพื่อแยกไฟล์

อาจจำเป็นต้องรวม

-a_srs epsg:4326

ธง


0

ขนาดพิกเซลของคุณแตกต่างกันในไฟล์ของคุณ GDAL บ่นเกี่ยวกับเรื่องนั้นดู:

ตอนนี้, คุณต้องมีขนาดพิกเซลเท่ากัน คุณจะต้องลองกริดของคุณอีกครั้งหรือทำซ้ำกริดตั้งแต่เริ่มต้น GMT เป็นเครื่องมือที่ดีสำหรับสิ่งนั้น

โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.