[R-sig-Geo] Map labels
tom sgouros
tomfool at as220.org
Mon Nov 23 15:45:37 CET 2009
Roger Bivand <Roger.Bivand at nhh.no> wrote:
> > Being near the water, there are lots of islands, so each town is
> > represented by a bunch of polygons. How do I select only one to be
> > labeled, and is there a convention for which one would be the best to
> > use? I see the labpt slot, in my SpatialPolygonsDataFrame object, but I
> > don't see a mostAppropriateLabpt or primaryLabpt or anything like that.
> >
> > In addition to this, I get no errors when I follow the examples at
> > http://r-spatial.sourceforge.net/gallery/ , but I see no labels, either.
> >
> > This is what I'm doing. Are the colors covering my labels?
> >
> > spplot(rep.map,zcol="vote02",at=breaks,col.regions=rg,
> > layout=list(list("sp.text",getSpPPolygonsLabptSlots(rep.map)[25,],"HERE I AM")))
> >
>
> Thanks for the verbatim code. I think that you need to name the
> argument sp.layout= rather than layout=. Because of the ... argument
> list, layout= doesn't get rejected, but it doesn't get used
Thank you, that works perfectly.
> list("sp.text", coordinates(rep.map), row.names(rep.map))
>
> to put the FID value (feature ID) at the centroid of the largest
> member polygon (Polygon object) of the entity (Polygons object), for
> each entity of the data set.
This doesn't, though. When I read in my data, the IDvar is supposed to
be the column that is unique for each record, correct? But there are
several records (closed polygons) for each town. These are linked by
another variable. The coordinates(rep.map) gives me a list of 419
coordinates for all the closed shapes, not 75 coordinates for all the
towns. How do I get the biggest polygons for each town? I have an Area
attribute, so I guess I can just calculate it. Is that the right way to
go, or is there some method already existing for this?
I thought maybe my readSpatial... was done wrong, so I changed the IDvar
to point to the iD for each town, but that gives me an error saying that
duplicate row names are not allowed. Is there a step I needed to take
to link the polygons?
Thank you,
-tom
--
--------------------------------------------------------
Check out "Ten Things You Don't Know About Rhode Island"
http://whatcheer.net http://sgouros.com
More information about the R-sig-Geo
mailing list