我刚开始使用NetCDF文件,但我无法在其他地方找到问题的答案。
2015年每日降水数据(来自Gridmet):https://www.northwestknowledge.net/metdata/data/pr_2015.nc
我的问题:地图显示的是x轴上的lat,y轴上的long。如何翻转这些轴?此外,似乎纬度的值也被反转。 (见下面链接的地图)
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, jabatzoglou@uidaho.edu
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"
>
提前感谢您的帮助。非常感谢!
答案 0 :(得分:2)
您可以使用光栅包中的transpose
和flip
组合:
s <- stack("pr_2015.nc", varname="precipitation_amount")
s2 <- t(flip(s, direction='y' ))