Skip to content

plot projected xyz

2 messages · Rosa Trancoso, Roger Bivand

#
Hello!

I'm having trouble making a map of terrain elevations.
I have a collection of (lon,lat, z) points. These points have regular 
spacing (20km) when projected, but not in geographical coordinates.

So I project the data and make a SpatialGRidDataFrame object with sp and 
rgdal packages.
How can I plot it with lon,lat axes? By costumizing the axes?
Is there a way to define the projection I am working on and do all the 
work with lon,lat coordinates?


Thanks in advance,
Ana Rosa
#
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