Displaying 5 results from an estimated 5 matches for "blackcel".
Did you mean:
blackcell
2018 May 20
1
How to average values from grid cells with coordinates
Hi lily,
It's not too hard to do it using dataframes. Getting the indexing
right is usually that hardest part:
# these values are the centers of the black cells
lat<-rep(28:38,11)
lon<-rep(98:108,each=11)
pop<-sample(80:200,121)
# just use the data.frame function
blackcells<-data.frame(lat=lat,lon=lon,pop=pop)
plot(0,type="n",xlim=c(97.5,108.5),ylim=c(27.5,38.5),
xlab="Longitude",ylab="Latitude")
abline(h=27.5)
abline(h=lat+0.5)
abline(v=97.5)
abline(v=lon+0.5)
text(blackcells$lon,blackcells$lat,pop)
# the red cells will be centered...
2018 May 16
0
How to average values from grid cells with coordinates
...t; cells fall at the corners of four "black" cells.
You can get the four "black" cells by finding the lat/lon values that
are closest to the "red" lat/lon values. Here's a basic example:
lat<-rep(28:38,11)
lon<-rep(98:108,each=11)
pop<-sample(80:200,121)
blackcells<-list()
for(i in 1:121) blackcells[[i]]<-list(lat=lat[i],lon=lon[i],pop=pop[i])
redcell<-list(lat=33.5,lon=100.5,pop=NA)
close4<-rep(NA,4)
closen<-1
for(i in 1:121) {
if(abs(blackcells[[i]]$lat-redcell$lat) < 1 &&
abs(blackcells[[i]]$lon-redcell$lon) < 1) {
close...
2018 May 22
0
How to average values from grid cells with coordinates
Hi Jim,
Thanks. It works. I now have more complex problems. If at each blackcell,
there are two variables such as pop and mood. For each variable, there are
daily records in one year, so 365 records for pop and 365 records for mood.
The averaged values for the redcells should be daily records too. What kind
of format do you recommend for this problem? Right now, I just get the...
2018 May 16
5
How to average values from grid cells with coordinates
Hi R users,
I have a question about data processing. I have such a dataset, while each
black grid cell has a few attributes and the corresponding attribute
values. The latitude and longitude of the center of each grid cell are
given also.
Then I want to average the attribute values from four adjacent grid cells
to get the average value for the center of each red grid cell. Thus, there
are the
2018 May 19
0
How to average values from grid cells with coordinates
Hi lily,
You could also create "blackcells" as a dataframe (which is itself a
type of list). I used a list as I thought it would be a more general
solution if there were different numbers of values for different grid
cells. The use of 1 for the comparison was due to the grid increments
being 1. If you had larger or smaller grid incre...