Hi everybody,
I'm trying to use colPalette and/or strokeColor arguments in the function
plotGoogleMaps to have different colors for values in the data.frame
columns.
I can't get the correct map, and always get a warning message.
I tried the following (reproducible) code:

library(maptools)
library(rgdal)
library(plotGoogleMaps)

nc <- readShapePoly(system.file("shapes/sids.shp",
package="maptools")[1], proj4string=CRS("+proj=longlat +datum=NAD27"))

#First I tried colouring polygons and border differently...
nc1=nc
nc1@data=data.frame(City_Name=nc@data$NAME,NWBIR74=nc@data
$NWBIR74,BIR74=nc@data$BIR74)
nc1Fill=rep("green",length(nc1@data$City_Name))
nc1Bord=nc1Fill
nc1Fill[nc1@data$NWBIR74>300]="red"
nc1Bord[nc1@data$BIR74>2000]="yellow"
nc1Bord[nc1@data$BIR74>10000]="red"

MaiMap<-
plotGoogleMaps(nc1,filename='MyMap.htm',mapTypeId='TERRAIN',colPalette=nc1Fill,strokeColor=nc1Bord)
#here I get the following warning message:
#In `levels<-`(`*tmp*`, value = c("green", "green", "green", "green",  :
#  duplicated levels will not be allowed in factors anymore

#borders are all green


#Than I tried with 2 layers, as here:
nc1=nc
nc1@data=data.frame(City_Name=nc@data$NAME,NWBIR74=nc@data$NWBIR74)
nc1Fill=rep("green",length(nc1@data$City_Name))
nc1Fill[nc1@data$NWBIR74>300]="red"
nc2=nc
nc2@data=data.frame(City_Name=nc@data$NAME,BIR74=nc@data$BIR74)
nc2Fill=rep("green",length(nc2@data$City_Name))
nc2Fill[nc2@data$BIR74>2000]="yellow"
nc2Fill[nc2@data$BIR74>10000]="red"

MaiMap1<- plotGoogleMaps(nc1,mapTypeId='TERRAIN',colPalette=nc1Fill,
add=TRUE)
MaiMap2<-
plotGoogleMaps(nc2,filename='MyMap.htm',colPalette=nc2Fill,previousMap=MaiMap1)
#here I get the same error , but map colors are wrong.

Any suggestion?
Thanks,
Luca.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to