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. Thank you
Code:
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 .