[R-sig-Geo] Apply() function on 3rd dimension of SpatialGridDataFrame

Nathalie Morin Nathalie.M.Morin at Usherbrooke.ca
Wed Dec 19 21:04:21 CET 2012


Hello,

 

I have a 3D array with an attribute converted to SpatiaGridDataFrame named
“clip’ :

 

> summary(clip)

Object of class SpatialGridDataFrame

Coordinates:

         min       max

s1 828104.00 828134.00

s2 101839.00 101869.00

s3    324.09    373.09

Is projected: TRUE

proj4string :

[+init=epsg:27561 +proj=lcc +lat_1=49.50000000000001
+lat_0=49.50000000000001 +lon_0=0

+k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515

+towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs]

Grid attributes:

   cellcentre.offset cellsize cells.dim

s1         828104.50        1        30

s2         101839.50        1        30

s3            324.59        1        49

Data attributes:

    Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 

   0.000    0.000    0.000    0.002    0.000    0.806 9506.000

 

The apply() function does not work on the 3rd dimension of the
SpatiaGridDataFrame :

 

> D.tls.z.mean <- apply(clip, 3, mean, na.rm=T)

 

=> I get an error message (sorry it's in French) :

"Erreur dans if (d2 == 0L) { : valeur manquante là où TRUE / FALSE est
requis"

 

I tried with z coordinate instead :

> z <- coordinates(clip)[,3]

> D.tls.z.mean <- apply(clip, z, mean, na.rm=T)

 

The only solution I found is to convert back to standard non spatial 3D
array.

 

Cheers,

 

Nathalie MORIN

Doctorante en télédétection forestière (Ph.D student in remote sensing
applied to forestry)

Centre d’application et de recherches en télédétection (CARTEL)

Département de Géomatique Appliquée

Sherbrooke (QC) CANADA J1K 2R1

Tél. : + 1 (819)  821-8000 #62962

e-mail :  <mailto:Nathalie.M.Morin at Usherbrooke.ca>
Nathalie.M.Morin at Usherbrooke.ca

 <http://www.usherbrooke.ca/> Université de Sherbrooke

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20121219/bd61efd6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1245 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20121219/bd61efd6/attachment.gif>


More information about the R-sig-Geo mailing list