[R-sig-Geo] Levelplot (raster) and xyplot (SpatialPoints) together with both legends in a single plot

Navinder Singh Navinder.Singh at slu.se
Wed Sep 30 01:24:51 CEST 2015


Hi List,
I am trying to overlay a xyplot of spatialpoints on top of a level plot of a raster stack.
My code looks like :
>p<-levelplot(allYrStack.diff,layout=c(6,2),main="Differences", par.settings=RdBuTheme)
# allYrStack.diff is a raster stack
>striptext = factor(inds.mig$month, levels = unique(inds.mig$month))
>p+xyplot(y~x|striptext,groups=COUNTRY, type="o",data = inds.mig, pch = 20, size=0.2, colour = inds.mig$id,alpha=0.5)

# y=y coordinate, x=xcoordinate, etc..Country is a fatcor variable which can have 10 levels. so is the id variable.
I now intend to have both the legends on the plot (one for the continuous values from the raster and another for colour coded variable country with a line and a dot in the middle), but i am unable to add the legend of data plotted in the xyplot on the main plot. I understand that to get the legend of xyplot also, i should probably create an empty space first, and then add both the level plot and xyplot and their legends, so that i have space for both.
However, my skills are failing me this time.
Any suggestions are most helpful.
Thanks and best wishes,
Navi

Navinder J Singh
Associate Professor
Department of Wildlife, Fish, and Environmental Studies
Faculty of Forest Sciences
Swedish University of Agricultural Sciences
SE-901 83 Umea, Sweden
O: +46 (0)90 786 8538;
M: +46 (0)70 676 0103
email: navinder.singh at slu.se<mailto:navinder.singh at slu.se>
Web: navinderjsingh.weebly.com<http://navinderjsingh.weebly.com/>

www.slu.se/viltfiskmiljo/navinder_singh<http://www.slu.se/viltfiskmiljo/navinder_singh>
http://slu-se.academia.edu/NSingh
Moose Work: http://moose-research.se/
Golden Eagles: http://www.goldeneaglesweden.com/
Beyond Moose: http://wildsamm.weebly.com/








	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list