2016-12-05 12 views
1

Я новичок в работе с файлами NetCDF, и я не смог найти ответ на мой вопрос в другом месте.Растровый график климатических данных Netcdf вращается в R

Ежедневно засветки данные за 2015 год (от Gridmet): https://www.northwestknowledge.net/metdata/data/pr_2015.nc

Мой вопрос: Карты отображения с Lat на оси х и долго на оси у. Как перевернуть эти оси? Кроме того, также представляется, что значения для широты инвертируются. (См связанный карту ниже)

library(raster) 
    library(ncdf4) 
    nc15 <- nc_open("C:\\Users\\vsteen\\Desktop\\BorealToad\\Climate\\pr_2015.nc")   
    b <- brick("C:\\Users\\vsteen\\Desktop\\BorealToad\\Climate\\pr_2015.nc",varname="precipitation_amount") 
    plot(b[[3]]) 



    print(nc15) 
1 variables (excluding dimension variables): 
    float precipitation_amount[lat,lon,day] 
     units: mm 
     description: Daily Accumulated Precipitation 
     _FillValue: -32767 
     esri_pe_string: GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]] 
     coordinates: lon lat 
     cell_methods: time: sum(interval: 24 hours) 
     missing_value: -32767 

3 dimensions: 
    lon Size:1386 
     units: degrees_east 
     description: longitude 
    lat Size:585 
     units: degrees_north 
     description: latitude 
    day Size:365 
     units: days since 1900-01-01 00:00:00 
     calendar: gregorian 
     description: days since 1900-01-01 

9 global attributes: 
    author: John Abatzoglou - University of Idaho, [email protected] 
    date: 20 September 2016 
    note1: The projection information for this file is: GCS WGS 1984. 
    note2: Citation: Abatzoglou, J.T., 2013, Development of gridded surface meteorological data for ecological applications and modeling, International Journal of Climatology, DOI: 10.1002/joc.3413 
    last_permanent_slice: 365 
    last_early_slice: 365 
    note3: Data in slices after last_permanent_slice (1-based) are considered provisional and subject to change with subsequent updates 
    note4: Data in slices after last_early_slice (1-based) are considered early and subject to change with subsequent updates 
    note5: Days correspond approximately to calendar days ending at midnight, Mountain Standard Time (7 UTC the next calendar day) 

str(nc15$dim) 

    List of 3 
    $ lon:List of 10 
    ..$ name   : chr "lon" 
    ..$ len   : int 1386 
    ..$ unlim  : logi FALSE 
    ..$ group_index : int 1 
    ..$ group_id  : int 65536 
    ..$ id   : int 0 
    ..$ dimvarid  :List of 5 
    .. ..$ id   : int 0 
    .. ..$ group_index: int 1 
    .. ..$ group_id : int 65536 
    .. ..$ list_index : num -1 
    .. ..$ isdimvar : logi TRUE 
    .. ..- attr(*, "class")= chr "ncid4" 
    ..$ units  : chr "degrees_east" 
    ..$ vals   : num [1:1386(1d)] -125 -125 -125 -125 -125 ... 
    ..$ create_dimvar: logi TRUE 
    ..- attr(*, "class")= chr "ncdim4" 
    $ lat:List of 10 
    ..$ name   : chr "lat" 
    ..$ len   : int 585 
    ..$ unlim  : logi FALSE 
    ..$ group_index : int 1 
    ..$ group_id  : int 65536 
    ..$ id   : int 1 
    ..$ dimvarid  :List of 5 
    .. ..$ id   : int 1 
    .. ..$ group_index: int 1 
    .. ..$ group_id : int 65536 
    .. ..$ list_index : num -1 
    .. ..$ isdimvar : logi TRUE 
    .. ..- attr(*, "class")= chr "ncid4" 
    ..$ units  : chr "degrees_north" 
    ..$ vals   : num [1:585(1d)] 49.4 49.4 49.3 49.3 49.2 ... 
    ..$ create_dimvar: logi TRUE 
    ..- attr(*, "class")= chr "ncdim4" 
    $ day:List of 11 
    ..$ name   : chr "day" 
    ..$ len   : int 365 
    ..$ unlim  : logi FALSE 
    ..$ group_index : int 1 
    ..$ group_id  : int 65536 
    ..$ id   : int 2 
    ..$ dimvarid  :List of 5 
    .. ..$ id   : int 2 
    .. ..$ group_index: int 1 
    .. ..$ group_id : int 65536 
    .. ..$ list_index : num -1 
    .. ..$ isdimvar : logi TRUE 
    .. ..- attr(*, "class")= chr "ncid4" 
    ..$ units  : chr "days since 1900-01-01 00:00:00" 
    ..$ calendar  : chr "gregorian" 
    ..$ vals   : num [1:365(1d)] 42003 42004 42005 42006 42007 ... 
    ..$ create_dimvar: logi TRUE 
    ..- attr(*, "class")= chr "ncdim4" 
    > 

Заранее спасибо за любую помощь. Это будет очень признательно!

Rotated U.S. precipitation map

ответ

1

вы можете использовать комбинацию transpose и flip из растрового пакета:

s <- stack("pr_2015.nc", varname="precipitation_amount") 

s2 <- t(flip(s, direction='y')) 
+1

Спасибо за ответ. Я пробовал s2, но процесс был медленным на моем компьютере, поэтому я ушел. Скорее, эта альтернативная версия сделала трюк: flip (t (s), direction = 'x') –