Hi list,
I have a problem to solve which I believe I shoudl use the convolve to solve
it, but I could not figure out how to do it.
I got mydata, which is a dataframe which has 7 locations, each location has
a longitude,latitude and a value.
considering a step of 0.5 degree for longitudes and latitudes, I got 15
points for longitude and 15 points for latitude. Then
I created a grid, mygrid, which has 15 columns for longitudes and 15 rows
for latitudes.
Now I want to have a circle which moves from mygrid[1,1] (column 1, row 1)
all the way to mygrid[15,15] (column 15, row 15), then it sums
the value in each cricle and retruns me a grid where each elements is the
aggregated value inside the circle. In other word lets say if
we are looking at the mygrid[1,1], we need a circle which has a centre point
which has a longitude of -4 and latitude of 52, then we aggregate the
values from mydata which are located inside the circle. Lets say circle has
a radius of 1 degree. Please take a look at the code I have added and help
me if you know how can use convolve. If you send me the code, I appreciate,
as I have already played with convolve, but it was so complicated.
thanks
Alireza
mydata<-data.frame(longitude=c(0,1,2,3,-1,-3,-4),
latitude=c(53,52,55,56,58,59,58.5),
value=c(232,333,5333,3233,53333,2233,3443))
plot(mydata$longitude,mydata$latitude)
nolong=seq(range(mydata$longitude)[1],range(mydata$longitude)[2],0.5)
nolat=seq(range(mydata$latitude)[1],range(mydata$latitude)[2],0.5)
mygrid<-matrix(0,nrow=length(nolat),ncol=length(nolong))
mycricle<-(radius of 2 degree)
[[alternative HTML version deleted]]