Skip to content

API documentation?

1 message · Roger Bivand

#
On Mon, 30 Jun 2008, tom sgouros wrote:

            
I would be happy to link to such a guide from the Spatial Task View, for 
example on the R-Geo site. There are other nice resources, for instance 
Dylan Beaudette's site - one page is:

http://casoilresource.lawr.ucdavis.edu/drupal/node/100

Seen from the developer side, it is hard to know what users see as the 
most useful advice. The courses that have been provided - say like:

http://www.bias-project.org.uk/ASDARcourse/

are rather "developer-view", as indeed the forthcoming "useR" series book 
will be. By "developer-view", I mean attempting to provide information 
both for beginning users and trying to advance along the useR-developeR 
continuum where experience has shown that this may be advisable, even 
though neither desired nor immediately applauded.

A typical immediate response to the courses has been that "all that class 
and coordinate reference system stuff is unnecessary". This seems to hold 
until the participants actually get to do work with their own data, at 
which point having a reference to what is going on is handy. The specific 
difficulty, as teachers often find, is that the initial expectation from 
the user is often not the most fruitful question for helping the user 
to become more self-reliant going forward.

One clear reason for this difficulty is that many different disciplines 
use spatial data, and all of them seem to feel that they know enough for 
their internal purposes, so get frustrated when they encounter barriers 
which are inherent in their perception(s) of spatial data. So listening to 
other disciplines and learning from them can be helpful.

As far as sp classes are concerned, is the R-News note of 2005 too 
outdated to be helpful? Should it be placed more prominiently on the Task 
View page? I would acknowledge that ease of use is not what it could be, 
we are still where time series (and time representation) were in R a 
couple of years ago. However, the sp classes ought to work for many who do 
not need to manipulate the actual coordinates. For working statisticians, 
simple mapping of model residuals is no more than:

library(sp)
library(rgdal)
mydata <- readOGR(dsn="directory", layer="shpfile")
# or:
# library(maptools)
# mydata <- readShapeSpatial("shpfile.shp")
# from release 0.7-14 already submitted to CRAN, now you have to know
# whether your shapefile is point, line or polygons
myobj <- lm(response ~ x1 + x2, data=mydata)
mydata$residuals <- residuals(myobj)
spplot(mydata, "residuals")

where the mydata Spatial*DataFrame behaves as a data.frame. The two-faced 
nature of the Spatial*DataFrame classes is intentional, looking like GIS 
data models for GIS people, and data frames for statisticians. But 
manipulating coordinates is just a good deal more complicated - unless 
you just need subsetting with the "[" methods.

To summarise, contributions of user tips and examples, and links to those 
examples, would be very welcome.

Roger