Skip to content

maptools issue

3 messages · MacQueen, Don, kun17

#
Hi all,

I want to use maptools to plot map, there are many plot examples in the
document, but I can not find the usage explaination for plot function as
well as the possible parameters.

Could someone give me advice?

Kun






--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/maptools-issue-tp7587580.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
1 day later
#
The first thing to do is to find out the class of the object you are
plotting. For example, in this example:

library(maptools)
xx <- readShapePoints(system.file("shapes/baltim.shp",
package="maptools")[1])
plot(xx)

Then:
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"



This indicates that you are using the plot() function from the sp package.
[1] "package:sp"       "package:graphics"


The plot function in the sp package is built on the plot function in the
graphics package, that is, the  plot() that is included with R. This
implies that the possible arguments include those of the basic plot
function. For example:

plot(xx, cex=2)
plot(xx, cex=2, col='red', pch=4)


Exactly what the additional arguments do depends on the class of the
object you're plotting.

For lines objects, see ?lines
For polygon objects, see ?polygons
For points objects, see ?points

(that list is an abbreviated version of Table 3.2 in the book Applied
Spatial Data Analysis with R, by Bivand, Pebesma, and Gomez-Rubio; get a
copy if you can!)

Final suggestion; if you are using the "read" functions from maptools as
in the example above, I would suggest installing the rgdal package and
using readOGR() instead. I think you will be better off in the long run
(and I'm pretty sure this is what the experts have been recommending).

-Don