标签: ncdf4

使用R转换为NetCDF时保留栅格变量名称

以每月的温度数据多年的光栅文件,它具有通过连接访问的名称names(object)按以下格式"Jan.1981",两年与下面的代码工作"Feb.1981"等(例如文件位置 -添加的所有文件太大了

使用以下代码读入并写入NetCDF:

#Load Packages
library(raster)
library(ncdf4)

#Read in temperature files
r1 <- brick('TavgM_1981.grd')
r2 <- brick('TavgM_1982.grd')

#stack them together 
TempStack = stack(r1, r2)

#set the coordinate system (as it was missing)
crs(TempStack) <- ('+proj=lcc +lat_1=53.5 +lat_2=53.5 +lat_0=46.834 +lon_0=5 +x_0=1488375 +y_0=-203375 +datum=WGS84 +to_meter=2500 +no_defs +ellps=WGS84 +towgs84=0,0,0')

#reproject to get in lat/lon instead of meters
TempStack<-projectRaster(TempStack, crs=CRS("+init=epsg:4326"))

#Extract monthly data names to assign to netCDf later
names <- names(TempStack)

#write the raster file to NetCDF
writeRaster(TempStack, "Temp.nc", overwrite=TRUE, …
Run Code Online (Sandbox Code Playgroud)

r raster netcdf r-raster ncdf4

5
推荐指数
1
解决办法
477
查看次数

在 R studio 中安装包“ncdf4”失败

我正在尝试安装一个名为“ncdf4”的 R 软件包。\n我已尝试将其安装在 R-studio 界面的“packages”部分,但也尝试输入install.packages("ncdf4")控制台。

\n\n

这是我在两种情况下得到的输出:

\n\n
Installing package into \xe2\x80\x98/home/user/R/x86_64-pc-linux-gnu-library/3.6\xe2\x80\x99\n(as \xe2\x80\x98lib\xe2\x80\x99 is unspecified)\ntrying URL \'https://cloud.r-project.org/src/contrib/ncdf4_1.17.tar.gz\'\nContent type \'application/x-gzip\' length 124458 bytes (121 KB)\n==================================================\ndownloaded 121 KB\n\n* installing *source* package \xe2\x80\x98ncdf4\xe2\x80\x99 ...\n** package \xe2\x80\x98ncdf4\xe2\x80\x99 successfully unpacked and MD5 sums checked\n** using staged installation\nconfigure.ac: starting\nchecking for nc-config... no\n-----------------------------------------------------------------------------------\nError, nc-config not found or not executable.  This is a script that comes with the\nnetcdf library, version 4.1-beta2 or later, and must be present for configuration\nto succeed.\n\nIf you installed the netcdf library (and …
Run Code Online (Sandbox Code Playgroud)

installation r package ncdf4

3
推荐指数
1
解决办法
6429
查看次数

标签 统计

ncdf4 ×2

r ×2

installation ×1

netcdf ×1

package ×1

r-raster ×1

raster ×1