[R-sig-Geo] plot.polylist polygon plot order

Jeff Jorgensen Jeff.Jorgensen at noaa.gov
Thu Jul 19 00:55:55 CEST 2007


Hi Bob,

Thanks for the suggestion.

I figured out a way to force the polygon plot order, by referencing one 
of the attributes of the imported shapefile.  The polygons I used were 
6th field HUCs and I was able to use this attribute to order plotting:

shape<-readShapePoly(shapefile)#shapefile has a HUC6 column
plot(shape,col=colorlist[shape$HUC6[1:n]])# where n is the total
                                          # number of polygons


I used your suggestion to add lines to polygons with no data (NA, i.e., 
no color), using a second plot call with your suggestions for density 
and angle, also with the "[shape$HUC6[1:n]]" suffix as above with 
colorlist, and set add = T.  Worked like a charm.


Thanks so much.

Jeff





#####################################
Hi Jeff,

This is what I did.

HistBreaks<-quantile(datafileDf$nhunters,probs=c(0.1,0.2,
0.4,0.6,0.8,0.9,1.0),na.rm=TRUE)
np<-findInterval(datafileDf$nhunters, histBreaks, all.inside=TRUE)
colorsToUse<-colorSchemeV5
plot.polylist(datafilePolys, col=colorsToUse[np],  forcefill=FALSE)
plot.polylist(datafilePolys,  density = c(-1,20,20,-1,-1,-1,-1)[np],
angle=c(0,0,90,0,0,0,0)[np], forcefill=FALSE,add=TRUE)

the first plot.polylist plots the outline of the polygon, the second
call "colors" the polygon.

I hope this helps.

Bob

-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Jeff Jorgensen
Sent: Wednesday, July 18, 2007 9:30 AM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] plot.polylist polygon plot order

Hello,

I've imported a shapefile of polygons (R v2.5.1 winxp, maptools v0.6-13)

and I'm trying to assign colors to polygons in plot.polylist().  Is
there a way to force the order in which polygons are plotted get the
correct color associations to the corresponding polygons?

Best regards,

Jeff


-- 
Jeff Jorgensen
Northwest Fisheries Science Center
National Marine Fisheries Service
NOAA Fisheries
2725 Montlake Blvd. E.
Seattle, WA  98112

jeff.jorgensen at noaa.gov
ph:   206.860.3286
FAX:  206.860.3400




More information about the R-sig-Geo mailing list