[R-sig-Geo] Color Ramp on SpatialLines Object
Rodrigo Aluizio
r.aluizio at gmail.com
Tue Mar 9 15:02:40 CET 2010
Hi List.
Im 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 Im able to color each item with the color I want (eg.:
col=c(col1,col2,etc)), but Im 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.: Im using the plot() function to draw the maps (probably a specific
panel variation of sp package).
Thank you for your attention, I hope you may help me.
-------------------------------------------------------------
MSc. <mailto:r.aluizio at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20100309/c630825e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4925 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20100309/c630825e/attachment.bin>
More information about the R-sig-Geo
mailing list