[R-sig-Geo] Change coordinates of a shapefile

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Mar 27 14:05:34 CEST 2012


On Tue, Mar 27, 2012 at 12:46 PM, Ralf Schäfer <senator at ecotoxicology.de> wrote:
> Dear list,
>
> I have a shapefile where the zone number of UTM has been placed as first digits of the x-values. So the bounding box is:
>  min      max
> x 33085892 33475738
> y  5801128  6059362
>
> I want to get rid of the 33 and thus extracted the coordinates from the SpatialLinesDataFrame and substracted the value:
> coordinates(data) -> coords
> length(coords) -> num_list
> for(i in 1:num_list){coords[i][[1]][[1]][,1] -33000000 ->   coords[i][[1]][[1]][,1] }
> coordinates(data) <- coords
> Unfortunately, I get an error when trying to write back.
>
> Any ideas how to accomplish this - may be there are also easier ways to change the coordinate system?!

 The 'elide' function in package:maptools has a 'shift' argument that
should let you subtract 33000000 from all coordinates...

Barry



More information about the R-sig-Geo mailing list