[Rspatial-devel] proj4string<-

Roger Bivand Roger.Bivand at nhh.no
Tue Mar 27 14:41:52 CEST 2012


On Tue, 27 Mar 2012, Edzer Pebesma wrote:

> I discovered today than a student assumed that in the following sequence:
>
> xx = readOGR('whatever shapefile')
> proj4string(xx) = "new proj4 string"
>
> would project to the new projection. The logic is that of
>
> coordinates(meuse) = c("x", "y")
>
> It doesn't, but also doesn't say it doesn't.
>
> https://stat.ethz.ch/pipermail/r-sig-geo/2012-March/014666.html
>
> is another case of the same assumption.
>
> I suggest to modify proj4string<- such that when it is called with a
> CRS, and the object already has a (non-NA) CRS, a message is printed
> that sais sth like:
>
> "A new CRS was assigned to an object with an existing CRS, without
> reprojecting. For reprojection, use function spTransform in package rgdal".

Yes, that would make sense, but should it be a warning, or a message 
controlled by an option? I do it often with GRASS because rasters and 
vectors get different renderings of the same PROJ.4 string. So some users 
could turn off the warning; maybe a flag could be set to show the message 
once only too?

Roger

>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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 Rspatial-devel mailing list