[R-sig-Geo] plot shape file using lattice xyplot

Felix Andrews felix at nfrac.org
Wed Dec 16 23:41:31 CET 2009


What's wrong with using spplot? It is based on xyplot anyway.

If you want to use xyplot, you can use the panel function that sp defines:
sp.polygons(shp)

You can read in the shapefile with the RGDAL package:
shp <- readOGR(...)


2009/12/17 Zia Ahmed <zua3 at cornell.edu>:
> Hi,
>
> I am trying to plot a shape file  in R. I can do  it easily using plot or
> spplot function.  But I want plot this map with  lattice xyplot function.
> Any one has any idea? I do not want use "maps" package.
>
> Help will be appreciated...
>
> Thanks
>
> Zia
>
> library(maptools)
> library(lattice)
> bound<-read.shape("Boundary.shp")
> #OR
> bound<-readShapePoly("Boundary.shp")
> plot(bound)
> spplot(bound)
>
> # Or following way
>
> bound<-Map2poly(bound)
> xybd<-attr(bound,"maplim")
>
> plot(xybd$x,xybd$y, type="n",asp=1, xlab="", ylab="")
> for (i in 1:length(bound)) lines(bound[[i]]) # How do I apply this code in
> following  panel.function of  xyplot?
>
>
> windows(width=5, height=5)
> xyplot(y~x, as.data.frame(tala),pch=1, cex=.8,col="black",
>      xlab=list("Easting (m)",cex=.9),ylab=list("Northing (m)",cex=.9),
>      aspect = "iso",
>      panel = function(...) {
>             panel.xyplot(...)
>             panel.abline(h = 0:4*5000 + 545000, v= 0:4*5000 + 2650000,
>             col = "light grey")
>             panel.points(coordinates(tala.nr),cex=.95,pch=20, col="black")
>             panel.text(2671000, 563000, cex=1, " (a)")
>             },
> )
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/



More information about the R-sig-Geo mailing list