[R] Maps in R - Rmap library announcement
Barry Rowlingson
B.Rowlingson at lancaster.ac.uk
Wed Jan 8 14:01:17 CET 2003
Its a shame that there exists several map packages that all use
different data file formats.
So I started writing a package that will be independent of any file
format, once we've written methods for each file format, that is.
My Rmap project is now available in a rather buggy but hey it works version:
http://www.maths.lancs.ac.uk/Software/Rmap
What does it do? Well at the moment it can only handle ESRI shapefiles,
but I'm working on an OGR driver that will open the window to many file
formats for zero effort. OGR is included in GDAL - see my web page for
links.
The basic idea is to present the map layer as a data frame. Columns of
the data frame represent attributes of the entities (polygons, lines,
points) and rows represent each entity. So you can do this:
africa <- shapefile("/u/data/africa.shp")
mapplot(africa)
mapplot(africa[africa$name=="KENYA",])
and even:
myFit <- lm(pop~area,data=africa)
Isn't that neat? How about something like:
mapplot(africa,fill=popcolour(africa$population))
and if you have the PROJ4 library installed, it can even do map
projections if your data is lat-long:
mapplot(africa, proj="+proj=ortho") # orthographic projection
mapplot(africa, proj="+proj=merc") # mercator projection
And you can use the inverse projection to get lat-long back from a
locator() on the graphics device.
I'm going to look at the RArcInfo and the map libraries and see what I
can borrow from them to solve some of the current problems with my Rmap.
Please feel (GPL) free to download and play with Rmap, but beware the
dreaded segmentation fault. Remember to save.image() early and
save.image() often. Its a bit awkward to install at the moment because
of its reliance on Shapelib and PROJ4, but we can fix that...
Enjoy!
Baz Rowlingson
Maths and Stats
Lancaster University
Lancaster, UK
More information about the R-help
mailing list