[R-sig-Geo] transforming a 3d SpatialGridDataFrame into a mesh of some kind

Mark Connolly mark_connolly at acm.org
Wed Dec 9 19:29:18 CET 2009


I _think_ raster may be solving a different problem.  I am looking for a 
voxel-type raster.  Let me know if I am wrong.

plot3d(raster(kriged_sp))
Error in as.double(x) :
  cannot coerce type 'S4' to vector of type 'double'

Let me describe the SpatialGridDataFrame a bit better.  The coordinates 
are position in volumetric space (x,y,depth_cm).  The value at each 
position is the predicted value from IDW (var1.pred).  So the structure is

summary(kriged_sp)
Object of class SpatialGridDataFrame
Coordinates:
              min      max
x        740317.2 740747.2
y        181326.1 181646.1
depth_cm    -90.0      0.0
Is projected: TRUE 
proj4string :
[+init=epsg:32119 +proj=lcc +lat_1=36.16666666666666
+lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0
+ellps=GRS80 +datum=NAD83 +units=m +no_defs +towgs84=0,0,0]
Number of points: 2
Grid attributes:
         cellcentre.offset cellsize cells.dim
x                 740322.2       10        43
y                 181331.1       10        32
depth_cm             -87.5        5        18
Data attributes:
   var1.pred        var1.var    
 Min.   : 3.66   Min.   :   NA  
 1st Qu.:19.92   1st Qu.:   NA  
 Median :22.97   Median :   NA  
 Mean   :22.08   Mean   :  NaN  
 3rd Qu.:24.62   3rd Qu.:   NA  
 Max.   :44.26   Max.   :   NA  
                 NA's   :24768  




When I create a raster from this object, I get something that looks 
two-dimensional:

class       : RasterLayer 
filename    :  
nrow        : 32 
ncol        : 43 
ncells      : 1376 
min value   :  
max value   :  
projection  : +init=epsg:32119 +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs +towgs84=0,0,0 
xmin        : 740317.2 
xmax        : 740747.2 
ymin        : 181326.1 
ymax        : 181646.1 
xres        : 10 
yres        : 10 



Robert J. Hijmans wrote:
> Mark,
>
> If spgdf is a SpatialGridDataFrame object
>
> # install.packages("raster", repos="http://R-Forge.R-project.org")
> library(raster)
> plot3D(raster(spgdf))
>
> Or you can have a look at the code:
> getMethod("plot3D", 'RasterLayer')
>
> Robert
>
> On Wed, Dec 9, 2009 at 5:10 AM, Mark Connolly <mark_connolly at acm.org> wrote:
>   
>> I have a 3d SpatialGridDataFrame I created using krige (IDW).  I am using
>> rgl facilities to create an interactive plot of the points, but I'd really
>> like to have something more volumetric than points.  My copy of the truly
>> wonderful Applied Spatial Data Analysis with R (shameless pander) is pretty
>> mute on 3d.  Any hints on where I might find something on transforming the
>> points into a mesh?  Something I need to code for myself?
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>     
>
>



More information about the R-sig-Geo mailing list