Doubt in Extract function (raster)

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Doubt in Extract function (raster)

Pietro Andre Telatin Paschoalino
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.

[]<>    Virus-free.<>

        [[alternative HTML version deleted]]

R-sig-Geo mailing list
[hidden email]