Skip to content
Prev 378 / 29559 Next

sp: a package with classes and methods for spatial data in R

Very cool. I'd been thinking of something similar, but not had the time
to act on it. Looks like we need to add OGR wrappers to rgdal so that
vector data can be read in.

A couple of immediate items I noticed:

1) "sp" is rather terse, no? I like more descriptive package names.

2) I think it is always a good idea to let typing describe internal
states (ie making objects stateless). It leads to much cleaner
interfaces and many fewer coding errors. If there are two different ways
to represent a grid, make two classes. If they are perfectly
substitutable (functions can take either), join them with a super-class.
If one is a perfect subset of the other, then make it the parent class
and the extension the child (inherits). See GDALDataset and
GDALReadOnlyDataset. GDALDataset is a perfect superset of
GDALReadOnlyDataset and so can be passed to any function needing the
interface of GDALReadOnlyDataset. This is formalized by having
GDALDataset inherit from GDALReadOnlyDataset. If you are writing
functions that check or update the internal states of your objects
(except ordinary insertion and deletion of contained items), then you
should think twice about the object hierarchy. This is why there are no
"is.writable" or "make.writable" functions in rgdal. That's all handled
by type declarations (meaning you can customize dispatch on types in
your methods ;-)

3) As long as we can override methods of the interface, all will be
well. We can substitute external data representations when we need to
scale to larger datasets. Try allocating a 50Kx50K matrix in R. There
will be times when we will want to have data be in a database or on disk
and still manipulate it with the "sp" interface. I don't see any
barriers to this at the moment. These external wrappers will want to
inherit from existing classes, so see point 2 above.

Love the image gallery! Nice work!

THK
On Thu, 2005-04-14 at 18:43 +0200, Edzer J. Pebesma wrote: