recenter-methods.Rd
Methods for function recenter
in package sp to shift or re-center geographical coordinates for a Pacific view. All longitudes < 0 are added to 360, to avoid for instance parts of Alaska being represented on the far left and right of a plot because they have values straddling 180 degrees. In general, using a projected coordinate reference system is to be preferred, but this method permits a geographical coordinate reference system to be used. This idea was suggested by Greg Snow, and corresponds to the two world representations in the maps package.
recenter a SpatialPolygons object
recenter a Polygons object
recenter an Polygon object
recenter a SpatialLines object
recenter a Lines object
recenter an Line object
crds <- matrix(c(179, -179, -179, 179, 50, 50, 52, 52), ncol=2) SL <- SpatialLines(list(Lines(list(Line(crds)), "1")), CRS("+proj=longlat +ellps=WGS84"))#> Warning: Discarded datum Unknown based on WGS84 ellipsoid in CRS definitionbbox(SL)#> min max #> x -179 179 #> y 50 52#> min max #> x 179 181 #> y 50 52rcrds <- rbind(crds, crds[1,]) SpP <- SpatialPolygons(list(Polygons(list(Polygon(rcrds)), ID="r1")), proj4string=CRS("+proj=longlat +ellps=WGS84"))#> Warning: Discarded datum Unknown based on WGS84 ellipsoid in CRS definitionbbox(SpP)#> min max #> x -179 179 #> y 50 52#> min max #> x 179 181 #> y 50 52par(opar) crds <- matrix(c(-1, 1, 1, -1, 50, 50, 52, 52), ncol=2) SL <- SpatialLines(list(Lines(list(Line(crds)), "1")), CRS("+proj=longlat +ellps=WGS84"))#> Warning: Discarded datum Unknown based on WGS84 ellipsoid in CRS definitionbbox(SL)#> min max #> x -1 1 #> y 50 52#> min max #> x 1 359 #> y 50 52rcrds <- rbind(crds, crds[1,]) SpP <- SpatialPolygons(list(Polygons(list(Polygon(rcrds)), ID="r1")), proj4string=CRS("+proj=longlat +ellps=WGS84"))#> Warning: Discarded datum Unknown based on WGS84 ellipsoid in CRS definitionbbox(SpP)#> min max #> x -1 1 #> y 50 52#> min max #> x 1 359 #> y 50 52par(opar)