0

I'm using the 'gstat' package to calculate precipitation values in unknown grids based on known grid values. These grid values pertain to the current location (lon, lat) of a precipitation gauge . The number of rain gauges in northern Canada is limited. To estimate precipitation in unknown grids, I use the following codes.  Any grid that is not within 100 kilometres of the precipitation gauge should produce NA, however it does not. Is there anything you could suggest?

x<-Daily_Precip$Lon
y<-Daily_Precip$Lat
z<-Daily_Precip$Precipitation
 
knowndt=data.frame(x,y,z)   #Known Lon, Lat and Location parameter values
coordinates(knowndt)<-~x+y

Daily_grid<-read.csv(file.choose()) # I would like to estimate on the grid lon and lat of this file 

x1<-Daily_grid$Lon
y1<-Daily_grid$Lat
 
unknowndt<-data.frame(x1,y1)        
coordinates(unknowndt)<-~x1+y1

idwmodel_Daily_Precip_idp2=idw(z~1, knowndt,unknowndt,nmin =4, nmax=10,maxdist=100,idp=2) # Testing for idp=2

predZ_Daily_Precip_idp2=idwmodel_Daily_Precip_idp2@data$var1.pred
Daily_r1i1p1_idp2<-data.frame(x1,y1,predZ_Daily_Precip_idp2)

write.csv(Daily_Precip_idp2,"Daily_r1i1p1_idp2_Location.csv",row.names=FALSE) # Saving as a csv file
divibisan
  • 11,659
  • 11
  • 40
  • 58
R Program
  • 11
  • 1
  • The code you provided is not useful. Please consider adding code that 1) is minimal and complete, meaning it does not contain extra lines of code not needed for the specific question and 2) is reproducible, meaning you provide sample data for us to recreate the error. See [this link](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for more information. – jpsmith Feb 04 '22 at 15:54
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 12 '22 at 01:04

0 Answers0