[R-sig-Geo] Am i misusing the shift() option in elide(maptools) function?

Roger Bivand Roger.Bivand at nhh.no
Sun Dec 9 18:34:37 CET 2007


On Sun, 9 Dec 2007, zhijie zhang wrote:

> Dear friends,
>  I used the shift() option in elide(maptools) function to shift the x/y
> coordiates, but it seemed that it didn't change the coordinates.
> #Programs used by me
> library(sp)
> library(foreign)
> library(maptools)
>
> data(meuse)  #in the help page
> coordinates(meuse) <- c("x", "y")
> proj4string(meuse) <- CRS("+init=epsg:28992")
> data(meuse.riv)
> river_polygon <- Polygons(list(Polygon(meuse.riv)), ID="meuse")
> rivers <- SpatialPolygons(list(river_polygon))
> proj4string(rivers) <- CRS("+init=epsg:28992")
>
> #rivers
> Slot "coords":
> [176,] 182003.7  337678.6
> Slot "bbox":
>        min      max
> r1 178304.0 182331.5
> r2 325698.5 337684.8
>
>
> rivers1 <- elide(rivers, shift=c(10000,-10000))  #,shift southeast to 10000,
> but it seems unchanged
> #rivers1
> #the coordinates were the same as that of rivers
> Slot "coords":
> [176,] 182003.7  337678.6
> Slot "bbox":
>        min      max
> r1 178304.0 182331.5
> r2 325698.5 337684.8
>
> Q: Am i misusing the shift() option in elide(maptools) function? Where goes
> wrong?

Thanks for a very clear report, this was a bug. The shift= argument worked 
for points but not for lines or polygons. The next release of maptools 
will correct this, and add rotation options kindly contributed by Don 
MacQueen.

Roger

> Thanks.
>

-- 
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