Agustin Lobo wrote:
> Roger,
> 
> I think that having Arithmetic operations defined for 
> SpatialGridDataFrame objects would be very useful.

  The problem is that SpatialSomethingDataFrame objects don't inherit 
data.frame's behaviour (with respect to mathematical operators). Perhaps 
if R's OO implementation was a bit more conventional you'd get this for 
free by subclassing data.frame.

  But data.frame isn't subclassable properly. A SpatialPointsDataFrame 
is an S4 object with a data frame in the @data member. In order to 
implement data.frame-like behaviour, it is necessary to implement 
methods for SpatialPointsDataFrame that work on the @data object - for 
example, dim:

dim.SpatialPointsDataFrame = function(x) dim([EMAIL PROTECTED])

  It should be almost as equally trivial to implement the arithmetic 
operators - they would work on the @data member and leave the 
coordinates untouched. Although what happens to the coordinates if you 
add two spatial data frames with different coordinates (but the same 
shape of data frame)? I would be tempted to either make sdf1 + sdf2 
return a plain data frame - and if the user wants to slap coordinates on 
it they can take it from sdf1 or sdf2 - or always use the coords from 
the first argument.

Barry

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to