[R] sp: proj4string has no impact

Roger Bivand Roger.Bivand at nhh.no
Wed Jan 17 19:56:00 CET 2007


On Wed, 17 Jan 2007, Albrecht Kauffmann wrote:

> Hi all,
> 
> I'm faced with a problem applying the sp package: The projection argument in
> 
> readShapePoly(Shapefile,proj4string="CRS class argument")
> 
> e.g.: CRS("+proj=aea +lat_1=46 +lat_2=73 +lat_0=60 +lon_0=84 +x_0=0
> +y_0=0 +ellps=clrk66 +units=m  +no_defs")
> 
> doesn't have any impact on the plotted object. I also tested the simple
> example:
> 
> xy = cbind(x = 2 * runif(100) - 1, y = 2 * runif(100) - 1)
> plot(SpatialPoints(xy, proj4string =
> CRS("+proj=longlat")),xlim=c(-1,1),ylim=c(-1,1))
> 
> looks exactly like
> 
> plot(SpatialPoints(xy, proj4string =CRS("+proj=stere +lon_0=98  +over"))
> 
> or
> 
> plot(SpatialPoints(xy))
> 
> without any projection.
> 
> What I'm doing wrong?

What impact would you like? The vertical scaling adjustment for 
geographical coordinates ("+proj=longlat") is proportional to the distance 
of the midpoint of ylim from the Equator, so in your case no adjustment 
would be expected:

library(sp)
set.seed(1)
x <- runif(20, -10, 10)
y <- runif(20, -10, 10)
par(mfrow=c(3,2))
plot(SpatialPoints(cbind(x, y)), axes=TRUE)
plot(SpatialPoints(cbind(x, y), proj4string=CRS("+proj=longlat")), 
axes=TRUE)
plot(SpatialPoints(cbind(x, y+50)), axes=TRUE)
plot(SpatialPoints(cbind(x, y+50), proj4string=CRS("+proj=longlat")), 
  axes=TRUE)
plot(SpatialPoints(cbind(x, y+70)), axes=TRUE)
plot(SpatialPoints(cbind(x, y+70), proj4string=CRS("+proj=longlat")),
  axes=TRUE)
par(mfrow=c(1,1))



> 
> I use the latest versions of sp and rgdal.
> 
> With many thanks for any hint,
> 
> Albrecht Kauffmann
> Potsdam University
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

-- 
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-help mailing list