[R-sig-Geo] Doubt in Extract function (raster)
Pietro Andre Telatin Paschoalino
P|etro_te|@to @end|ng |rom hotm@||@com
Fri Aug 28 20:09:55 CEST 2020
Hello everyone,
I have a simple question regarding extracting climatic data from raster to shape (polygons).
I am extracting climatic data, for example precipitation, from a raster (nc file) following the structure:
fn <-file.path ("mypath")
ncfile <- nc_open (fn)
rasbrick <- stack (fn)
how it is a multiband and I want just a few of them:
rasbrick <- rasbrick [[70:71]]
finally, I extract to the columns that I want:
for (i in 1: length (rasbrick @ layers)) {
weath_dt [, 4 + i] = raster :: extract (rasbrick [[i]], shape2, mean)
}
Could you confirm what I understand in the R documentation?
* In this case, I am extracting only the simple average of the values of the cells that have centroid inside the polygon, correct?
* Would you know to inform me why, when I ask for it to be weighted by the area of the cell within the polygon (weights = TRUE) I receive more missing values than asking just the average? Shouldn't it be the other way around?
Sorry if the question is too basic. If necessary I can try to do some example, but I believe it must be a "general" question, not depending much on my data, but maybe I'm wrong.
Thank you very much.
Pietro Andre Telatin Paschoalino
Doutorando em Ciências Econômicas da Universidade Estadual de Maringá - PCE.
[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon> Virus-free. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list