Skip to content
Prev 2869 / 29559 Next

plot projected xyz

On Thu, 29 Nov 2007, Rosa Trancoso wrote:

            
See ?gridlines and ?gridat in the sp package to construct a grid and label 
it. If you construct the grid in geographical coordinates and project it 
using spTransform() methods in rgdal to the projection of the data, you 
can overplot your projected data with a longlat grid:

library(rgdal)
scot_BNG <- readOGR(system.file("vectors", package = "rgdal")[1],
   "scot_BNG")
scot_LL <- spTransform(scot_BNG, CRS("+proj=longlat +datum=WGS84"))
grd_LL <- gridlines(scot_LL, ndiscr=100)
summary(grd_LL)
grd_BNG <- spTransform(grd_LL, CRS(proj4string(scot_BNG)))
grdtxt_LL <- gridat(scot_LL)
grdtxt_BNG <- spTransform(grdtxt_LL, CRS(proj4string(scot_BNG)))
plot(scot_BNG)
plot(grd_BNG, add=TRUE, lty=2)
text(coordinates(grdtxt_BNG),
   labels=parse(text=as.character(grdtxt_BNG$labels)))

is an example.

Roger