[R-sig-Geo] plot projected xyz
Roger Bivand
Roger.Bivand at nhh.no
Thu Nov 29 20:01:49 CET 2007
On Thu, 29 Nov 2007, Rosa Trancoso wrote:
> 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?
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
>
>
> Thanks in advance,
> Ana Rosa
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list