Hello dear friends,
When I am converting ('nc4' file to 'tif' format ) I get the following warning?
Warning message:
In .gd_SetProject(object, ...) : NOT UPDATED FOR PROJ >= 6
I am using the following code:
library(sp)
library(Rcpp)
library(raster)
library(lwgeom)
setwd("D:/TRMM/TRMM FOR TRY")
getwd()
#Step-1
library(maptools)
library(rgdal)
#td <- tempfile()
#dir.create(td)
#Sys.setenv("PROJ_USER_WRITABLE_DIRECTORY"=td)
#library(rgdal)
#readShapePoly(file.choose( ))
readOGR(file.choose())
afg_shape<-readOGR(file.choose())
plot(afg_shape)
st_crs(afg_shape)
plot(afg_shape[2,])
plot(afg_shape[1,])
#Step-2
library(utils)
library(bitops)
library(RCurl)
library(sp)
library(sf)
library(raster)
library(Rcpp)
library(R.methodsS3)
library(R.oo)
library(R.utils)
library(gdalUtils)
library(ncdf4)
library(renv)
library(GD)
library(PROJ)
library(proj4)
library(projects)
library(rgeos)
library(ggplot2)
library(tidyr)
library(meteo)
library(tmap)
library(leaflet)
library(dplyr)
#install.packages("sp", type = "source")
#into<-"3B42_Daily.19980101.7.nc4"
#outo<-"3B42_Daily.19980101.7.tif"
fname<-file.choose()
nc<-nc_open(fname)
var<-brick(fname,varname="precipitation")
r<-stack(var)
#crs(afg_shape)<-crs(r)
extent(r)<-extent(60,75,29,39)
t<-writeRaster(r,filename ="3B42_Daily1.19980101.7.tif.tif",format="GTiff",overwrite=TRUE)
print(t)
crs(t)
crs(afg_shape)
crs(t)<-crs(afg_shape)
#step3
M<-raster::extract(t,afg_shape,fun=mean)
M2<-raster::extract(t,afg_shape[1,],fun=mean)
###################----------------------
####Method1
stack()
brick()
M<-matrix(NA,3,5)
for (i in 1:1)
{
t<-stack(file.choose())
M[i,]<-raster::extract(t,afg_shape,fun=mean)
}
####Method2
fileAddress<-list.files(getwd(),pattern = "*.tif",full.names = TRUE)
M<-matrix(NA,length(fileAddress),5)
for (i in 1:length(fileAddress))
{
t<-stack(fileAddress[i])
M[i,]<-raster::extract(t,afg_shape,fun=mean)
}
###for one watershade
fileAddress<-list.files(getwd(),pattern = "*.tif",full.names = TRUE)
M<-matrix(NA,length(fileAddress),1)
for (i in 1:length(fileAddress))
{
t<-stack(fileAddress[i])
M[i,]<-raster::extract(t,afg_shape[2,],fun=mean)
}
write.table(M,file = "M.CSV",sep = ",")