everyone I am just a beginner of R,so following code or question might misunderstand R function. Hopes you guys don't mind it.
I got hundreds ERA Interim Daily Precipitation data from ECMWF.
Each monthly NetCDF file contain twice per day precipitation and extract them by Longitude & Latitude.
Finally convert to CSV file,but itself store (12:00 ;00:00) two columns for same days rainfall.
Ideally ,I would like to obtain single day rainfall for whole year or month. But, don't know how to do it in R.
Q1: Is there any library or function support merge columns names and keep same dates?
Q2: However, I am not sure lubridate library can accomplish or others will be better.
-----Thanks for any answers---------
If somebody want to view NetCDF file and .csv file ,you can get from my google driver: https://drive.google.com/drive/folders/1ogQp_-MlvmJCDmzm38dXHbUmWAM6hi1v?usp=sharing P.S In Google Drive SumMonth.csv is extract result
R Code:
library(raster)
library(ncdf4)
f <- list.files("C:/Users/asus/Downloads/extract",
pattern = "*.nc", full.names = TRUE)
ncloop <-lapply(f,nc_open)# Read whold folder nc.file
brick <-lapply(f,brick,varname = "tp")
brick2 <-stack(brick)# Combine all month
dim(brick2)#check dim right
##### input location file with Lon&Lat
pointCoordinates <- read.table("C:/Users/asus/Downloads/pointFile.csv",
header = TRUE, sep = ",",stringsAsFactors=FALSE)
coordinates(pointCoordinates) <- ~Long + Lat # Assign XY for extract
rasValue=extract(brick2, pointCoordinates)#extract
combinePointValue=cbind(pointCoordinates,rasValue)#construct database
## Outout as csv
cc <- as.data.frame(combinePointValue)
write.csv(cc,file ="SumMonth.csv")