Skip to content
Prev 27236 / 29559 Next

Selecting a range of longitude and latitudes

Hi Mike (and everyone),

Thanks for this reply!?
Let's say that I wanted to average the values of every grid cell within, say, 103 to 116 degrees longitude and 5 to 16 degrees latitude. Would there be a way to select all of those grid cells to average them? I've done something like this to already compute the averages across all grid cells based on values :
RCP1pctCO2ModelMean <- (Model2 + Model10 + Model18 + Model26 + subset14 + Model42 + subset20 + subset24 + Model60 + Model68) / 10 ? ###This provides an average value across each of the 140 layers for each of the 8192 grid cells based on these 10 models (i.e. all of the layer 1s are averaged for each model for the first grid cell, then all of the layer 2s are averaged for the first grid cell.....all the way to layer 140. Then, this is repeated for the second grid cell....all the way to grid cell 8192). This way, I have 140 averages across all grid cells. :)
So, to average values ONLY across a selected range of grid cells, is there a way to do that??
Thanks, again,


-----Original Message-----
From: Michael Sumner <mdsumner at gmail.com>
To: rain1290 <rain1290 at aim.com>
Sent: Fri, Apr 19, 2019 6:36 pm
Subject: Re: [R-sig-Geo] Selecting a range of longitude and latitudes

You want expand.grid(get, Hope2) to get every coordinate, but

coordinates(Model2)? ## gives a matrix (topleft, across rows, then
down same as values(Model2))

is far easier, albeit having been through layers of interpretation of
the original arrays in the file.

All the best, Mike


On Fri, Apr 19, 2019 at 11:51 AM rain1290--- via R-sig-Geo
<r-sig-geo at r-project.org> wrote: