0

I am trying to extract precipitation data from a NetCDF file for 425 points which I have in a CSV file, into a new CSV file. The output CSV file shows all the values as NA. What is the issue and how can I resolve it. I am attaching my code, and a snap of the output file below

setwd("D:/Wasif/Adjusted data/Datasets")
library (raster)
library(sp)
library(ncdf4)

station.data = read.csv(file.choose(), sep = ",", header =T) ## import station data.file
lat.long = station.data[,c(2,3)] ## extract data of all stations in station file for which point values are to be extractd
lat.long = SpatialPoints(lat.long) ## lat.long for further use
lat.long
robject = brick(file.choose(), varname = "PPT")## import raster netcdf file from which point values are to be extractd
dim(robject) ## check the dimensions of project
vall = extract(robject , lat.long, method = "simple" ) ## extract values
vall = t(vall)
write.csv(vall, file = "Observed.csv", fileEncoding = "macroman") ## save output csv file containing extracted point values .

Output file

mhovd
  • 3,724
  • 2
  • 21
  • 47
Wasif
  • 1
  • Hi! In your last line of code, does the problem persist if you remove `fileEncoding = "macroman"`? Or if you change it to `fileEncoding = "utf-8"`? – Juan Bosco Apr 29 '22 at 21:58
  • Yes... the problem persists – Wasif Apr 30 '22 at 22:06
  • If possible, add a small sample of the data, that reproduces your error, to your question, following the recommendations here https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Juan Bosco May 01 '22 at 03:09

0 Answers0