Dear Nathalie, 3D and higher-D support for Points Pixels and Grids in sp is there on the level of object creation, but very limited on the level of useful functionality.
apply() is not even a generic, so can only be applied to arrays, according to ?apply. Would an as.array(clip) method for SpatialGridDataFrame help you further? Or is it something else you need, e.g. clipping a SpatialGridDataFrame with more than 2 dimensions? On 12/19/2012 09:04 PM, Nathalie Morin wrote: > 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.mo...@usherbrooke.ca> > nathalie.m.mo...@usherbrooke.ca > > <http://www.usherbrooke.ca/> Université de Sherbrooke > > > > > > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- Edzer Pebesma Institute for Geoinformatics (ifgi), University of Münster Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de http://www.52north.org/geostatistics e.pebe...@wwu.de _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo