Hi Rodrigo,

One way to designate colors to SpatialLines Object is like this exmple on 
maptools package

library(maptools)
res <- ContourLines2SLDF(contourLines(volcano))
plot(res, col=terrain.colors(nrow(as(res, "data.frame"))))
title("Volcano contours as SpatialLines")

if you want to use colorRampPallet, try some like this:

test.col = colorRampPalette(c("red","white","blue"),space="rgb")
test.col(10)
plot(res, col=test.col(10))
title("Volcano contours as SpatialLines")



------------------------------------------------------------------------------------
Gledson Luiz Picharski
Bolsista de Iniciação cintífica - PIBIC/CNPQ
LEG (Laboratório de Estatística e GeoInformação)
Universidade federal do Paraná
e-mail: gled...@leg.ufpr.br
http://www.leg.ufpr.br/~gledson
------------------------------------------------------------------------------------





________________________________
De: Rodrigo Aluizio <r.alui...@gmail.com>
Para: r-sig-geo@stat.math.ethz.ch
Enviadas: Terça-feira, 9 de Março de 2010 11:02:40
Assunto: [R-sig-Geo] Color Ramp on SpatialLines Object


Hi List.
I’m preparing  a map for color
publication and some colleagues of mine which participate on this work, asked
me to put the bathymetric lines in a color ramp of deepness (eg.: light blue to
dark blue) just to create an didactic effect.
Well, this bathymetric data are stored in
SpatialLinesDataFrame Object imported from ShapeFiles with the readOGR (package
rgdal) function. Here is a summary of the object:

Object of class SpatialLinesDataFrame
Coordinates:
         min       max
r1 -53.01238 -26.92788
r2 -35.74499   7.03177
Is projected: FALSE 
proj4string :
[+proj=longlat +ellps=WGS84 +datum=WGS84
+no_defs +towgs84=0,0,0]
Data attributes:
 OBJECTID_1      OBJECTID            COTA     
 Min.   :   1           Min.   :   1            Min.  
:  25  
 1st Qu.: 570       1st Qu.: 570        1st
Qu.: 850  
 Median :1139   Median :1139    Median
:1900  
 Mean   :1139     Mean   :1139      Mean  
:2128  
 3rd Qu.:1708     3rd
Qu.:1708      3rd Qu.:3250  
 Max.   :2277      Max.  
:2277       Max.   :5750  
                                             
 SHAPE_Leng                     Shape_Le_1                      LAYER     
 Min.   :  0.04632               Min.  
:    5079                    4000   : 120  
 1st Qu.:  0.35611             1st Qu.:  
39116                 3500   : 119  
 Median :  0.61498           Median :  
67435              3000   : 103  
 Mean   :  2.58294            Mean   : 
279864               3250   :  95  
 3rd Qu.:  1.13124            3rd
Qu.:  123223               3750   :  93  
 Max.   :123.74401           Max.   :13320334              2500  
:  89  
                                                                                
              (Other):1658

Well I can plot it without any problem in a
map with other ShapeFiles (SpatialPolygonsDataFrame in this case) imported in
the same way. With the Polygons I’m able to color each item with the
color I want (eg.: col=c(‘col1’,’col2’,’etc’)),
but I’m not able to do so with the Lines object (neither with the 
col=c(‘col1’,’etc’)
or the col=c(colorRampPalette(c(‘initcol’,’endcol’))
function), when I try it the same way I did with the Polygons, only the first
specified color is applied to all lines and the others are ignored, if I try
with the colorRampPalette function nothing is plotted and I got a lot of
warnings (cor especificada não é nem numérica nem caracter == specified color
is not numeric neither character)

So, here is the doubt, is there a way to designate
specific colors to each line of a SpatialLines* Object?
Ps.: I’m using the plot() function to
draw the maps (probably a specific panel variation of sp package).

Thank you for your attention, I hope you
maSpatialLinesy help me.

-------------------------------------------------------------
MSc. Rodrigo Aluizio
Centro
de Estudos do Mar/UFPR
Laboratório
de Micropaleontologia
Avenida Beira
Mar s/n - CEP 83255-000
Pontal
do Paraná - PR - Brasil
________________________________
[[elided Yahoo spam]]
elebridades - Música - Esportes


      
____________________________________________________________________________________
[[elided Yahoo spam]]

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to