[R-sig-Geo] Subscripting by coordinates

Agustin Lobo Agustin.Lobo at ija.csic.es
Fri Jun 15 18:38:01 CEST 2007

Hi r-sig-geos,

I'm starting to use package sp
and can't figure how to subscript an sp grid
object by coordinates. This is what I do:

First, I read the raster image of the example:

x <- GDAL.open(system.file("pictures/erdas_spnad83.tif", package = 
erdas_spnad83 <- asSGDF_GROD(x, output.dim=c(100,100))

Then I simplify to only 4 levels
test <- erdas_spnad83
test2 <- erdas_spnad83 at data
test2[test2<50]<- 1
test2[test2>1 & test2 <100]<- 2
test2[test2>2 & test2 <150]<- 3
test2[test2>=150]<- 4
test at data <- test2

and make an small example
test3 <- test[1:10,11:20]

and then perform an stratified sampling:
test3.stsamp <- spsample(test3, n = 10, "stratified")

Now, I would like to get the values of test3 at positions 
test3.stsamp at coords,
test3[test3.stsamp at coords]

does not work. How should I do it?



Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es

More information about the R-sig-Geo mailing list