Using sp's aggregate, I wanted to take the mean moisture of each country which seemed to work as expected:
statesAg <- aggregate(mst_1950_sf["moisture"], by = world2015$geometry, mean)
plot(statesAg)
Looked good to me - but aggregating this way drops all other variables and I don't see a way to retain other variables of interest.
> names(statesAg)
[1] "moisture" "geometry"
Thus, I merged the new data with my previous dataset to get the other variables of interest back. When checking the results, however, I noted that for many countries several "means" had been returned.
What has happened here? Which mean is the actual mean of the respective countries, and which ones was the one plotted above? I would be very glad about any hint about what's been going on.
Hello everyone,
I am trying to aggregate fine-graned global climate grid data to multipolygons (first countries, later on the subnational level).
To accomplish this, I now have two shapefiles at hand, one containing the disaggregated climate data, the other the country geometries.
A glimpse at the climate data:
And the second shapefile:
Using sp's aggregate, I wanted to take the mean moisture of each country which seemed to work as expected:
Looked good to me - but aggregating this way drops all other variables and I don't see a way to retain other variables of interest.
Thus, I merged the new data with my previous dataset to get the other variables of interest back. When checking the results, however, I noted that for many countries several "means" had been returned.
What has happened here? Which mean is the actual mean of the respective countries, and which ones was the one plotted above? I would be very glad about any hint about what's been going on.
Thanks!