[R-sig-Geo] How to put name in map?
Roger Bivand
Roger.Bivand at nhh.no
Mon Feb 1 18:28:43 CET 2010
On Mon, 1 Feb 2010, Everton Emanuel wrote:
> Dear all,
>
> I have a small problem concerning labelling regions and areas in R. I want
> to label a single polygon in a map. I succeed labelling to whole map, but
> when I try a single polygon it did not work.
>
> This is the command that I used:
>
> #for the whole area it works#
> plot(map)
> centroids<-coordinates(map)
> text(centroids,label=map$NAME)
>
> #for a single polygon in whole map, it does not work#
> plot(map)
> centroids<-coordinates(map)[10,1:2]
> text(centroids,label=map$NAME)
Maybe:
centroids <- coordinates(map)[10, 1:2, drop=FALSE]
text(centroids, label=map$NAME[10])
Roger
>
> I appreciate any help.
> Thank you all.
>
>
--
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.Bivand at nhh.no
More information about the R-sig-Geo
mailing list