[R-sig-Geo] spplot : varying dots for multiple parameters

Torleif Markussen Lunde torleif.lunde at cih.uib.no
Wed Dec 16 16:03:29 CET 2009


Hi

You could try  par.settings in combination with str(spplot(whatYouWantToPlot))

If I understand you correctly you want to do something like:

# read data
Insitu = read.table("test.csv", skip=3,sep=",", na.string = "NaN")
Header = read.table("test.csv", skip=1,sep=",",nrows=1)
names(Insitu)= as.character(as.matrix(Header))
# define projection
CRS_4326 = CRS("+init=epsg:4326")

# convert to sp
Insitu_sp <-
SpatialPointsDataFrame(cbind(Insitu[,"Boylam"],Insitu[,"Enlem"]),
data=Insitu, proj4string=CRS_4326)

# subset data
idx = is.na(Insitu[,"SPM"])
Insitu_sp <- Insitu_sp[!idx,c("SPM","Si","LUT","HEX")]

# if you want relative differences among group #
# will cause LUT not to be plotted since they are all 0 or NA
# Divide all columns by maximum value in column
# do not run if you want to plot all data. 
max.na <- function (x) max(x, na.rm = TRUE)
maxVal <- apply(slot(Insitu_sp, "data"), 2, max.na)
slot(Insitu_sp, "data") <- data.frame(t(apply(slot(Insitu_sp, "data"), 1, 
      function (x) x/maxVal)))
# End if you want relative differences among group #

# define the stuff you want
north <- list("SpatialPolygonsRescale", layout.north.arrow(),
    offset = c(28.85, 36.735), scale = 0.02)
scale <- list("SpatialPolygonsRescale", layout.scale.bar(),
    offset = c(29, 36.735), scale = 0.1, fill = c("transparent",
        "black"))
txt1 <- list("sp.text", c(29, 36.745), "0")
txt2 <- list("sp.text", c(29.1, 36.745), "1 km")

my.layout <- list(txt1,txt2,scale,north)

# define point size
# note that the breaks are set according to the max and min values 
# in all(!) columns. Therefore standardization might be an idea (above)
ptsize <- seq(.5, 1.5, 
	      length.out=
		length(levels(spplot(Insitu_sp)$panel.args.common$groups)))

# (sp)plot
spplot(Insitu_sp, pch = 16, 
         col.regions = "red", # set colors
	 par.settings = list(
	  superpose.symbol = list(
           cex = ptsize)), # set point size
	 sp.layout = my.layout,
	 key = list(text = 
		      list(levels(spplot(Insitu_sp 
			    )$panel.args.common$groups)), 
	    points = list(pch=16, cex = ptsize, col="red"))) # add legend



Best wishes
Torleif

Torleif Markussen Lunde
Research fellow
Centre for International Health/
Bjerknes Centre for Climate Research
University of Bergen
Norway






On Wednesday 16 December 2009 13:23:38 servet ahmet çizmeli wrote:
> > Until you have control of the graphic itself, do not worry about
> > decorations, they are not important.
> 
> Dear Roger,
> 
> As an educator, I understand your willingness to direct me to what you
>  think is essential in the learning of R and I appreciate it very much.
>  However right now I need to produce these maps and they need to be of very
>  good quality as they will go into an important scientific report whose
>  deadline is very near. This is why I am calling my actual experience in R
>  "agonizing" right now!
> 
> I just want to make sure that I know very well how precious the time of
>  each and every one of this list so I would not ask a question just for
>  sake of easy learning. I ask questions when I really need something to be
>  done (and I do it only after I have tried every possible thing I could
>  think of).
> 
> Anyway, many thanks again, Roger and everyone on the list for your kindly
> support. Let us keep the good vibe. Right now I enjoy a lot reading and
>  reading in all kinds of R and R-spatial documentation and learning through
>  experimenting in a real project with a deadline ;o) ...
> 
> Servet
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 



More information about the R-sig-Geo mailing list