On Fri, 13 Feb 2009, Peter S. Hayes wrote:
Hi All,
I'm trying to teach a spatial analysis class using R as a means of learning
some details... I'm not an expert in R myself, but am learning it while using
it as a 'tool' for lessons in the class...
In getting the students familiar with some of the SP classes, we began
looking at the class components and manipulating some of the components (such
as translating by modifying coordinates..).
Is there a means of decomposing SpatialPolygons to access the list of
Polygons and contained classes? The help files (for example, polygons())
appear to hint so, but not function so... the SpatialPolygons isn't quite a
traditional R dataframe and won't flatten with a call to as.data.frame() to
allow access to the individual slots... but there must be a means of doing
that...
Perhaps look at the code in the elide methods in maptools - they all
access and manipulate the coordinate values in Spatial* objects. Usually
it is a matter of using lapply() on slots containing lists (the stacked-up
objects in Fig. 2.4, p. 40 in our book). lapply() lets you apply a
function to each member of a list - so one just steps inwards until one
gets to the slot with the coordinates in - updating the bbox slot on the
way out. spTransform methods in rgdal do this too. If you flatten the
representation, you'd get even worse spaghetti that the present
representation, which isn't ideal anyway.
Also, I have "Applied Spatial Data Analysis with R" as one of the texts...
any thoughts for more references... especially for non-programmers: I've some
software experience (C/C++...) but most of the students are environmental
study, environmental science, or biology students and this is one of their
first experiences with anything having a command line. We've been taking
things slow, but R is still a bit cryptic... any thoughts on that would be
appreciated!
You could try Braun & Murdoch: A First Course in Statistical Programming
with R. Cambridge University Press, Cambridge, 2007, or others on:
http://www.r-project.org/doc/bib/R-books.html
Hope this helps,
Roger
Thank you for all!
Pete
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo