[R-sig-Geo] Extract mean pixels values using circular samples

ASANTOS alexandresantosbr at yahoo.com.br
Sun Feb 5 18:20:41 CET 2017


Dear R-sig Member

      I'd like to extract mean pixels values using x,y coordinates by 
defining a buffer or area surrounding individual point coordinate. My 
circular sample represents the radius of a circular region around each 
point.  I try unsuccessfully this using extract function with raster 
package, in my hypothetical example:

require(raster)
require(sp)
require(plotrix)##Only for draw circular areas

## Create a raster
r <- raster(nc=30, nr=30)
r <- setValues(r, round(runif(ncell(r))* 255))
plot(r)

#Selection of center of coordinates of my circular samples
xd     <- c(-24.99270,45.12069,99.40321,73.64419)
yd  <- c(-45.435267,-88.369745,-7.086949,44.174530)
pts <- data.frame(xd,yd)
pts_s<- SpatialPoints(pts)

#Representation of target areas for sampling
for (i in 1:length(xd)) {
draw.circle(pts$xd[i],pts$yd[i],20,border="blue",col="grey")
}
points(pts_s, col="red", pch=16)


#Extract mean pixel values in 4 circular sample with radius=20
r_sample <- extract(x = r, y = pts_s, buffer=20, fun=mean, df=TRUE)
r_sample
# It doesn,t work!!!!!!


     Could someone please help me?

Thanks,

Alexandre

-- 
======================================================================
Alexandre dos Santos
Proteção Florestal
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial
Cáceres - MT                      CEP: 78.200-000
Fone: (+55) 65 99686-6970 (VIVO) (+55) 65 3221-2674 (FIXO)

         alexandre.santos at cas.ifmt.edu.br
Lattes: http://lattes.cnpq.br/1360403201088680
OrcID: orcid.org/0000-0001-8232-6722
Researchgate: www.researchgate.net/profile/Alexandre_Santos10
LinkedIn: br.linkedin.com/in/alexandre-dos-santos-87961635
Mendeley:www.mendeley.com/profiles/alexandre-dos-santos6/



More information about the R-sig-Geo mailing list