[R-sig-Geo] maptools issue

MacQueen, Don macqueen1 at llnl.gov
Fri Dec 26 17:58:41 CET 2014


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:
>  class(xx)
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"



This indicates that you are using the plot() function from the sp package.

> find('plot')
[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

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 12/25/14, 1:43 AM, "kun17" <kzhang at geo.ecnu.edu.cn> wrote:

>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.
>
>_______________________________________________
>R-sig-Geo mailing list
>R-sig-Geo at r-project.org
>https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list