0

I have tavg10km_reference_reference_1981_001.txt file with daily temperature data in ascii format. I am trying to convert it into .nc file. I used writeRaster command (script written below).

rm(list=ls())
library (raster)
library (ncdf4)
setwd("X:\\try\\")
txt<-raster("X:\\try\\tavg10km_reference_reference_1981_001.txt")
x <- writeRaster(txt, "tavg10km_reference_reference_1981_001.nc")

The new file is:

1 variables (excluding dimension variables):
float tavg10km_reference_reference_1981_001[easting,northing]   
_FillValue: -3.39999995214436e+38
missing_value: -3.39999995214436e+38
long_name: tavg10km_reference_reference_1981_001
min: -21.4279098510742
max: 18.6759605407715

 2 dimensions:
    easting  Size:72
        units: meter
        long_name: easting
    northing  Size:79
        units: meter
        long_name: northing
5 global attributes:
    crs: +proj=utm +zone=45 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
    crs_format: PROJ.4
    Conventions: CF-1.4
    created_by: R, packages ncdf4 and raster (version 2.6-7)

However, it does not have time dimension and I want to add time dimension. This is daily data of 1981-01-01. Any suggestion! Thank you in advance!

Santosh
  • 1
  • 3

0 Answers0