[R-sig-Geo] Help with spplot
Pierre Roudier
pierre.roudier at gmail.com
Wed Jun 8 23:49:15 CEST 2011
Hello Aritra,
If you want just the CRESS_ID column to be plotted, try:
spplot(nc, zcol = "CRESS_ID", col.regions = heat.colors(64))
If you want to have both maps on the plot:
p1 <- spplot(nc, "CRESS_ID", col.regions = heat.colors(64))
p2 <- spplot(nc, "both", col.regions = sample(rainbow(nboth)))
plot(p1, split=c(1,1, 2,1), more=TRUE)
plot(p2, split=c(2,1,2,1), more=FALSE)
HTH,
Pierre
2011/6/9 Aritra Sengupta <aritra.sourav at gmail.com>:
> Hello,
>
> I am trying to plot the map of NC and using a color scheme. I have done that
> using spplot().
>
> Here is a code (reference: Introduction to the North Carolina SIDS data
> set (revised), Roger Bivand, April 12, 2011)
>
> library(sp)
> library(maptools)
> library(spdep)
> nc_file <- system.file("etc/shapes/sids.shp", package = "spdep")[1]
> llCRS <- CRS("+proj=longlat +datum=NAD27")
> nc <- readShapeSpatial(nc_file, ID = "FIPSNO", proj4string = llCRS)
>
> nc$both <- factor(paste(nc$L_id, nc$M_id, sep = ":"))
> nboth <- length(table(unclass(nc$both)))
> spplot(nc, "both", col.regions = sample(rainbow(nboth)))
>
> Now I want to have the county index (CRESS_ID in nc) for each county,
> plotted on the same map. I have not been able to figure out how to do it :(
>
> Any help/suggestion will be greatly appreciated.
>
> Thanks.
>
> -Aritra
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Scientist
Landcare Research, New Zealand
More information about the R-sig-Geo
mailing list