<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Texte brut Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Texte de bulles Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.TextedebullesCar
{mso-style-name:"Texte de bulles Car";
mso-style-priority:99;
mso-style-link:"Texte de bulles";
font-family:"Tahoma","sans-serif";}
span.TextebrutCar
{mso-style-name:"Texte brut Car";
mso-style-priority:99;
mso-style-link:"Texte brut";
font-family:"Calibri","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR-CA link=blue vlink=purple><div class=WordSection1><p class=MsoPlainText><span lang=EN-US>Hello,<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-US>I have a 3D array with an attribute converted to SpatiaGridDataFrame named “clip’ :<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-US>> summary(clip)<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>Object of class SpatialGridDataFrame<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>Coordinates:<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US> min max<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>s1 828104.00 828134.00<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>s2 101839.00 101869.00<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>s3 324.09 373.09<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>Is projected: TRUE<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>proj4string :<o:p></o:p></span></p><p class=MsoPlainText>[+init=epsg:27561 +proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0<o:p></o:p></p><p class=MsoPlainText>+k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515<o:p></o:p></p><p class=MsoPlainText><span lang=EN-US>+towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs]<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>Grid attributes:<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US> cellcentre.offset cellsize cells.dim<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>s1 828104.50 1 30<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>s2 101839.50 1 30<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>s3 324.59 1 49<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>Data attributes:<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's <o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US> 0.000 0.000 0.000 0.002 0.000 0.806 9506.000<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-US>The apply() function does not work on the 3<sup>rd</sup> dimension of the SpatiaGridDataFrame :<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-US>> D.tls.z.mean <- apply(clip, 3, mean, na.rm=T)<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-US>=> I get an error message (sorry it's in French) :<o:p></o:p></span></p><p class=MsoPlainText>"Erreur dans if (d2 == 0L) { : valeur manquante là où TRUE / FALSE est requis"<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText><span lang=EN-US>I tried with z coordinate instead :<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>> z <- coordinates(clip)[,3]<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US>> D.tls.z.mean <- apply(clip, z, mean, na.rm=T)<o:p></o:p></span></p><p class=MsoPlainText><span lang=EN-US><o:p> </o:p></span></p><p class=MsoPlainText><span lang=EN-US>The only solution I found is to convert back to standard non spatial 3D array.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Cheers,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Nathalie MORIN<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Docto</span><span style='color:#595959;mso-fareast-language:FR-CA'>rante en télédétection forestière <i>(Ph.D student in remote sensing applied to forestry)</i></span><span style='color:#595959;mso-fareast-language:FR-CA'><o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Centre d’application et de recherches en télédétection (CARTEL)<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Département de Géomatique Appliquée<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Sherbrooke (QC) CANADA J1K 2R1<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>Tél. : + 1 (819) 821-8000 #62962<o:p></o:p></span></p><p class=MsoNormal><span style='color:#595959;mso-fareast-language:FR-CA'>e-mail : <a href="mailto:Nathalie.M.Morin@Usherbrooke.ca"><span style='color:#595959'>Nathalie.M.Morin@Usherbrooke.ca</span></a><o:p></o:p></span></p><p class=MsoNormal><a href="http://www.usherbrooke.ca/"><span style='font-size:9.5pt;font-family:"Verdana","sans-serif";color:#7F7F7F;mso-fareast-language:FR-CA;text-decoration:none'><img border=0 width=175 height=40 id="Image_x0020_1" src="cid:image001.gif@01CDDDFA.20449360" alt="Université de Sherbrooke"></span></a><span style='mso-fareast-language:FR-CA'><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>